Yes you can, to some extent by wrapping it in function call. What I typically do is to have a utility function which I can call upon whenever required.

Something like this:

popOpen: function (url, target, height, width) {
        var newWindow, args = "";
        args += "height=" + height + ",width=" + width;
        args += "dependent=yes,scrollbars=yes,resizable=yes";
        newWindow = open(url, target, args);
        newWindow.focus();
        return newWindow;
}

You can further reduce the parameters by making it an object like:

popOpen: function (params) {
        var newWindow, args = "";
        args += "height=" + params.height + ",width=" + params.width;
        args += "dependent=yes,scrollbars=yes,resizable=yes";
        newWindow = open(params.url, params.target, params.args);
        newWindow.focus();
        return newWindow;
}

And you can call it like this:

var param = { url: '...', height: '...', width: '...' };
popOpen(param);

Or,

var param = new Object;
param.url = '...';
param.height = '...';
popOpen(param);
Answer from Abhitalks on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN
The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name. ... A string indicating the URL or path of the resource to be loaded. If an empty string ("") is specified or this parameter ...
🌐
W3Schools
w3schools.com › jsref › met_win_open.asp
Window open() Method
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
Discussions

Javascript window.open() passing variables
The value in your window.open() is not for passing variables. That is to set the window parameters https://developer.mozilla.org/en-US/docs/Web/API/Window/open#parameters . Just use query string parameters. Something like this const params = new URLSearchParams(); params.set("a", 1); params.set("b", 2); const w = window.open(`myfile.html?${params.toString()}`); More on reddit.com
🌐 r/learnjavascript
7
1
August 18, 2024
window.open parameters as a variable
Within a function I have a line of code that opens a window whilst drawing its parameters either from the functions own parameters (u.n) or variables created within the function. This works fine i... More on stackoverflow.com
🌐 stackoverflow.com
How can I pass a parameter to a window.open command
I have a window.open command as ... "window.open('../help.php#Sale_Records','Help','width=1800,height=900,top=100,left=200')"); This works fine on my desktop but I’m sure the width and height will be too big for some computers so I would like to vary the parameters depending ... More on community.spiceworks.com
🌐 community.spiceworks.com
2
3
December 7, 2021
Javascript window.open confusing parameters? - Stack Overflow
This is default _parent - URL is ... of the window · I'm just wondering what false representing in my code thanks in advance... Sorry if not good question. JS newbie . ... Sign up to request clarification or add additional context in comments. ... see this scenario. currently my site is working in fullscreen and when i bind this function with a image. when i'm passing false and click on image then it opens a new tab ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Arai-a
arai-a.github.io › window-open-features
window.open with features
features parameter of window.open interacts with where the newly created browsing context is opened.
Top answer
1 of 2
2

The simple answer is yes. But make it a function that calculates those values when called. In other words:

let helpDimensions=function (w,h,l,t) {
return "width="+(w||findWidth())+", height="+h||findHeight()+", left="+(l||findLeft())+", top="+(t||findTop());
}
//this lets you pass a width, height, left, and top to override the calculated dimensions.
/*you will need to establish a findWidth(), findHeight(), findLeft(), and findTop functions or include them inline like:
return "width="+window.innerWidth*0.8+", height="+window.innerHeight*0.8+", left="0.1*window.innerWidth+", top="+window.innerHeight*0.1;
*/

/*then just perform function call like this:
window.open(url, title, helpDimensions()); to calculate the correct dimensions each time
*/

Also, establish a click handler on an element like this:

$("#someelement").on("click", function (e) {
e.preventDefault();
window.open("test.html","test", helpDimensions());
});

using jquery to set the onClick attribute of an existing element is a bad idea.
Also make sure that all of this is enclosed in an Immediate Invoked Injection Function or IIIF like this:

$(function () {
//define your helpDimensions function to calculate dimensions dynamically
//define your click event handler
});

//this ensures that it is not called until everything is loaded.

Hope this helps.
Here’s a great website for calculating dimensions and working with the window reference object to ensure that your content goes into the correct window (which can be reused if needed):

xtf.dk

Center a new popup window even on dualscreen with javascript

function PopupCenter(url, title, w, h) { // Fixes dual-screen position Most browsers Firefox var dualS...

2 of 2
3

I have a window.open command as follows:

$('#documentation_href').attr('onclick', "window.open('../help.php#Sale_Records','Help','width=1800,height=900,top=100,left=200')");

This works fine on my desktop but I’m sure the width and height will be too big for some computers so I would like to vary the parameters depending on the screen height.

I’ve successfully got some code to calculate the ideal values and have placed them into a parameter - the values vary depending on the screensize.

I’ve set this parameter as follows:

help_dimensions = 'width=' + help_width + ',height=' + help_height + ',left=' + help_left + ',top=' + help_top;

But I would like to know how I can use the parameter help_dimensions in my window.open command instead of the hardcoded values.

@nrgfusion

Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-window-open-method
JavaScript window.open() Method - GeeksforGeeks
August 5, 2025 - If an empty string is provided then it will open a blank new tab. windowName: It can be used to provide the name of the window. This is not associated with the title of the window in any manner.
🌐
PC SOFT
doc.windev.com › en-US
<Window>.Open (Function)
September 29, 2025 - .Open (Function) - Opens a modal WINDEV or WINDEV Mobile window.
🌐
Inductive Automation
forum.inductiveautomation.com › ignition
Passing New Parameters to an Existing Popup Window - Vision - Ignition - Inductive Automation Forum
January 19, 2024 - I am having issues updating the parameters on an already existing popup when more than one instance of that popup is open. My client wants me to add functionality that would allow them to right click any value in their …
🌐
JavaScript.info
javascript.info › tutorial › frames and windows
Popups and window methods
A name of the new window. Each window has a window.name, and here we can specify which window to use for the popup. If there’s already a window with such name – the given URL opens in it, otherwise a new window is opened.
Top answer
1 of 2
1

There are a number of issues here. First, of all, the values you use in your example (top=500,left=2000,height=600,width=400) are likely to put at least part of the window off screen. This will be automatically corrected by the browser. As MDN notes:

Requested position (top, left), and requested dimension (width, height) values in windowFeatures will be corrected if any of such requested value does not allow the entire browser popup to be rendered within the work area for applications of the user's operating system. In other words, no part of the new popup can be initially positioned offscreen.

Secondly, in the code where you are checking the position, you're actually reporting the main window's position, not the popup's. Instead of:

console.log("top=" + window.screenY + ", left=" + window.screenX);

That should be:

console.log("top=" + popwin.screenY + ", left=" + popwin.screenX);

This example correctly positions and reports the position of a popup window:

<!DOCTYPE html>
<head>
  <script type="text/javascript">
    function popup() {
      const popwin = window.open(
        "", 
        "", 
        "top=300,left=300,height=40,width=400,titlebar=no,popup=yes"
      );  
      popwin.document.write(`top=${popwin.screenY}, left=${popwin.screenX}`);
    }   
    popup();
  </script>
</head>
<body>
</body>
</html>

Lastly, concerning the address bar: it is in most modern browsers no longer possible to open a popup window without displaying the address bar, for security reasons. See more info in this answer.

In conclusion, there are better alternatives than using popups. They annoy users, and are routinely blocked by browsers. Depending on your use case, you could use something like a dialog element.

2 of 2
0

Try this code:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <title>Popup Test</title>
    </head>
    <body>
        <center>
            <p>test page for popup window</p>
        </center>
        <br />
        <br />
        <center><button onClick="newwin()">Click to open window</button></center>
        <br />
        <br />
        <script type="text/javascript">
            var popwin = null;

            function newwin() {
                // Get the current window position
                var top = window.screenY + 100;
                var left = window.screenX + 100;

                // Open a new window at the calculated position
                popwin = window.open(
                    "",
                    "",
                    `top=${top},left=${left},height=600,width=400,titlebar=no,scrollbars=yes,location=no`
                );
                popwin.document.write("<p>XXXXX</p>");

                console.log("top=" + top + ", left=" + left);
            }
        </script>
    </body>
</html>

This will correctly adjust the position of the new window

Make sure to adjust values as per your requirements

🌐
Mozilla Support
support.mozilla.org › en-US › questions › 1288277
Client Challenge
JavaScript is disabled in your browser · Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Coderanch
coderanch.com › t › 546661 › languages › Modifying-window-open-parameters
Modifying the window.open() parameters
July 25, 2011 - Im trying to use a JS function to call throw a pop as below Here IM being able to set the height ,width,top attributes correctly but none of the other parameters seem to work like resizable =no,or location =no. Why could this be happening? Learning and Learning!-- Java all the way! ... Modern day browsers have options built in to prevent the window from hiding those.
🌐
Medium
medium.com › front-end-weekly › passing-data-to-new-window-using-javascript-3637c3a17f76
Passing data to new window using JavaScript | by Abhishek Ankush | Frontend Weekly | Medium
November 5, 2024 - Query-Params: while launching the tab, if we need to pass few parameters to the new window then it can be achieved easily with query-params. // In source/launcher tab window.open('newtab.html?data=value'); // In destination/launched tab const params = new URLSearchParams(window.location.search); const value = params.get('data'); Simplicity: Easy to implement and understand, making it a straightforward choice for passing small amounts of data.
🌐
Spiceworks
community.spiceworks.com › programming & development
Passing form parameters using window.open()… - Programming & Development - Spiceworks Community
February 19, 2007 - Hello Frens, In my project, After entering the username, password and a click on submit button a popup window should open and this username and password shud be passed to that window this is my code : Username : Password : i am not able to pass username and password with the above code if i use form action=““xyz.jsp”” methos=““post”” target=““new”” i can pass username and password, but i am not able to set the window properties like width, height etc… please help me out thanx in advance…
🌐
Google Groups
groups.google.com › g › google-web-toolkit › c › 9BQFfiO6fzg
How to send Post-Data to Window.open?
This was taken from: ... window. The "name" and "features" arguments are specified here. Parameters: url - the URL that the new window will display name - the name of the window (e.g....