Click here to Skip to main content
15,885,887 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
this is my code

HTML
<pre><script type="text/javascript">
 function SysPopup(button, url, windowName, windowFeatures) {
window.open('http://www.google.com/','windowName1', 'top=100,left=300,width=200,height=200')
window.open('https://www.yahoo.com','windowName2' , 'top=150,left=350,width=300,height=300')
window.open('https://www.yandex.com','windowName3', 'top=200,left=400,width=400,height=400')
window.open('https://www.hotmail.com','windowName4', 'top=250,left=450,width=400,height=400')

//window.open(url,windowName,windowFeatures)// different name for each popup
// create windows as much as you want to create
}
</script>

</style>

</head>
<body bgcolor="black" margin-top=20px >

<br><br>


<br><br>
<input type="button" value="Open google" onclick="SysPopup('http://www.google.com/','windowName1', 'top=200,left=200,width=200,height=100' )"><br><br>

<input type="button" value="Open yaho" onclick="SysPopup('https://www.yahoo.com','windowName2' , 'top=230,left=230,width=400,height=400' )"><br><br>

<input type="button" value="Open yandex" onclick="SysPopup('https://www.yandex.com','windowName3', 'top=250,left=250,width=400,height=400'  )"><br><br>

<input type="button" value="Open hotmail" onclick="SysPopup('https://www.hotmail.com','windowName4')"><br><br>

my problem is when I run this code, the window opens at the top, but the window of the button pressed does not open when the buttons are mixed together


what I want is for it to open the right window even when I randomly press the buttons


What I have tried:

HTML
<pre><a href="http://google.com/" target="_blank">Open Window 1</a>
<a href="http://yahoo.com" target="_blank">Open Window 2</a>
<a href="http://yandex.com" target="_blank">Open Window 3</a>
Posted
Updated 8-Sep-21 0:44am

1 solution

You need to use the passed in parameters to open a specific window in the SysPopup function:
JavaScript
function SysPopup(button, url, windowName, windowFeatures) {
  window.open(url, windowName, windowFeatures)
}

See JavaScript Functions[^].
 
Share this answer
 
Comments
CL4Y3R-TR 8-Sep-21 6:56am    
the correct window opens when I press the button, but the new window and the old window should appear at the same time
Richard MacCutchan 8-Sep-21 7:05am    
Sorry, I do not know what you mean.
CL4Y3R-TR 8-Sep-21 7:25am    
the correct window opens when I press the button
CL4Y3R-TR 8-Sep-21 7:25am    
but all popup screens should be at the top of the screen at the same time
Richard MacCutchan 8-Sep-21 7:44am    
I have tried all different combinations of parameters described at Window open() Method[^], but each popup replaces the previous one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900