Multiple Windows using window.open()

So as we all know if you click on a submit button that has embedded in it a onClick(windown.open(...)) this opens a new window with all the lovely attributes you specify. However if then proceed to click on the parent window and again click on the ‘submit’ button without closing the previous popup window, then that same window is overwritten with the new data.

Now I need a way for that window.open() script to create new windows every time it is clicked. SO in theory I could click the parent “submit” button 2 consecutive times and have 2 different child windows appear.

I’m sure it’s trivial but I can’t seem to find anything.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Give each window a new window name.

window.open(url, WindowName)

Solution 2

try this,it will create new child, fiddle

var randomnumber = Math.floor((Math.random()*100)+1); 
 window.open(yoururl,"_blank",'PopUp',randomnumber,'scrollbars=1,menubar=0,resizable=1,width=850,height=500');

Solution 3

Check this this might help you to open new window every time.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery demo</title>
  <script src="jquery-1.9.1.js"></script>
</head>
<body>

<script>
$(document).on("click", "#btn", function(event) {
    window.open("http://www.google.com", '_blank');
});

</script>
<input type=button name="btn" id="btn">
</body>
</html>

Solution 4

window.open(url, '', 'width=1000, height=500')

then, you get new popup every time to click popupbutton.

Solution 5

In my case, the browser was blocking the pop-up window. I just allowed it to open the pop-up window.

Multiple Windows using window.open()

Solution 6

You need to disable Track outbound links which will open only one window. Add the following javascript code to index.html file:

<script type="text/javascript">
  var clicky_custom = clicky_custom || {};
  clicky_custom.outbound_disable = 1;
</script>

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply