Creating a new window using JavaScript with custom settings

Is it possible to create a window that opens when double clicking an icon on the desktop? I want this window to have specific dimensions and no menu bar or scrollbar.

This is what my current code looks like:

document.onload(openWin());

function openWin()
{
    document.open("index.htm","PoPuP", 'menubar=no, scrollbar=no, sizeable=no');
}

Upon loading the document, one page loads followed by another. Is there a way to prevent this?

Answer №1

Your approach seems a bit redundant, and there may be better ways to achieve your goal rather than using onload. It is advisable to utilize window instead of document in such scenarios, as the functionality of document.open may not align with your expectations. Consider using window.open for the desired outcome:

window.onload = function openWin() {
    window.open("index.htm","PoPuP", 'menubar=no, scrollbar=no, sizeable=no');
}

Answer №2

Looking to launch a website from a desktop hyperlink? JavaScript won't cut it — you need to use C# for that task. If you're interested in opening a URL in a popup window, check out my step-by-step guide:

There are two different approaches to this. You could include `TARGET="_blank"` in the anchor tag, but this method simply opens a new browser window that covers up the old one entirely.

Sometimes, though, displaying a small popup window on top of the main browser window is more effective. This type of small window is commonly referred to as a popup.

I'll begin by showing you the basic syntax for creating a popup, followed by an explanation of the script along with a list of common arguments you can apply to a popup and how to handle focus issues. Additionally, I will introduce a new method for adding popup functionality to a link; this approach is favored due to its cleaner implementation compared to the traditional method. Finally, I'll touch upon the challenges of directly inserting content into the popup, particularly the confusion surrounding the true URL of the popup.

To set up a popup, here's the necessary script:

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
    newwindow=window.open(url,'name','height=200,width=150,menubar=no, scrollbar=no, sizeable=no');
    if (window.focus) {newwindow.focus()}
    return false;
}

// -->
</script>

To link to the popup, use the following code:

<a href="popupex.html" onclick="return popitup('popupex.html')"
    >Link to popup</a>

Best of luck!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Combining the powers of $.get and $.ready

Basically, I am facing an issue with my ajax call where sometimes it completes before the page is fully loaded. I attempted to use $( fn ) to wrap the callback function, but unfortunately, the callback does not trigger if the page is already loaded. Does a ...

When a user clicks, they will be directed to the specific product page using Angular UI router

On my homepage, I have a JSON feed where all the products are displayed. When clicking on a specific product image, I want it to redirect to a separate page showing only that particular product. I understand that changes need to be made in the singleproduc ...

Utilizing a combination of MVC, jQuery, and Ajax to ensure that JavaScript is fully loaded before proceeding

Utilizing ASP.NET MVC and jQuery, I am loading a PartialView via Ajax which has its own accompanying JavaScript file. Upon successful retrieval of the html content, it is inserted into the DOM. However, there can be a delay between the insertion and the ex ...

View content from an external file within an iframe

My goal is to showcase a text file within an iframe that updates automatically every second. To achieve this, I have created a simple function: function refresh() { $("#derek").attr('src', $("#derek").attr('src')); }; The automati ...

Converting Json arrays to HTML tables using the window.chrome.webview.addEventListener feature with a Server Delphi Application

My Delphi application is sending Json data to the embedded Edge browser, but Javascript is reporting a parser error. https://i.sstatic.net/Z2BUq.png https://i.sstatic.net/0IIzJ.png When I modify the value for Sender.DefaultInterface.PostWebMessageAsJson ...

Issue with jQuery AJAX error callback not triggering upon encountering an error

I'm currently facing an issue with implementing the management of an HTTP 413: Request entity too large error from my server. I've made the following attempt to address it: $.ajax({ url: "submit.php", data: { "data": POSTData ...

Displaying queries using ajax in Rails

Can someone assist me in dealing with a particular issue? I am using ajax to refresh queries from the database dynamically each time there is a change in a search form. The main objective is to load N number of records based on the parameters selected in ...

After refreshing the page, the data stored in the localStorage array gets replaced

After refreshing the webpage, my localStorage array values are being overwritten. During a session, I am able to update values on the front end, and the array in localStorage gets updated accordingly. However, if multiple inputs are changed during a sessio ...

Using jQuery and AJAX to dynamically add data to POST parameters

Hello, I have a question that may sound like one from a newbie. I am trying to figure out how to insert a variable into a parameter for a POST request instead of simply writing the number in directly: var x = 3; id=(the var x needs to be here)&appid=4 ...

Using JavaScript to parse JSON data generated by PHP using an echo statement may result in an error, while

I am facing an issue with parsing a JSON string retrieved from PHP when the page loads. It's strange that if I send an AJAX request to the same function, the parsing is successful without any errors. The problem arises when I attempt to do this: JSON ...

Is there a method to introduce a line break for each piece of data that is shown?

I am currently working with an array and have successfully displayed it on the screen. My inquiry is whether it is feasible to insert a line break for each of the data points it presents. { name: "cartItems", label: "Product Name ...

Retrieve only the most recent input value

Currently, I am working with a text input to capture user input. As of now, here is my code snippet: $(myinput).on('input', function() { $(somediv).append($(this).val()); }); While I want to continue using the append function, I am facing an i ...

Is there a way to make an HTML link target the same as JavaScript window.opener?

Within my project, the main page is where users log in and access the primary tables. Additionally, there are numerous supplementary pages that open in separate windows. Once the login session times out, it is essential to restrict user access to any cont ...

Leveraging personalized design elements from a theme in Material UI without the need for makeStyles

Is there a way to access the theme.customElements.actionButton in MyComponent without relying on makeStyles? For instance, can I directly use className={theme.customElements.actionButton}? theme.js const theme = createMuiTheme({ customElements: { ...

Verify the accuracy of the properties received from mapStateToProps in a functional React Redux component

I am working with 3 components: TypeList, ConnectedType (connected through connect(mapStateToProps)(Type)), and the component Type. Type will receive props from both TypeList (onClick, name) passing props to ConnectedType as well as ConnectedType's ma ...

Steps for eliminating an element using jQuery from a variable filled with HTML code

I'm developing a forum where users have the ability to quote other users' comments. When a user clicks on "quote" for a comment, it captures the HTML of that comment and displays it in a box that says Quote: Original post by a member, similar t ...

Display HTML content retrieved from a string saved in a React database

I am currently in the process of creating a React page and facing a challenge with incorporating HTML content from a RTDB that has been styled using "use styles". Here is an example of the styling: import { makeStyles } from '@material-ui/core/style ...

Setting a default value for NULL property in TypeScript

Trying to establish a default value for all NULL objects has been quite the challenge. The current code looks like this: private setDisplayAmount(summaries: summary[]): void { summaries.map(t => { // performing some operations, and then... ...

items within the grid container are positioned without being constrained to rows and columns

After using the Container element, I noticed that all my grid items are displaying in columns instead of rows. How can I correct this layout issue? https://i.stack.imgur.com/9BjOA.png Click here to access the project link. ...

Removing a Dom element using stage.removeChild( )

When the number 6 is typed and entered into the game, the function correct() in the code snippet below determines what action to take. I would like to remove the DOM element gg (the equation 3+3=input) from the stage after typing 6 and pressing enter. How ...