Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.open question

Status
Not open for further replies.

DKL01

Programmer
Sep 14, 2000
233
0
0
US
Hi,

I have a link on my web page. On click, this link opens a new window using following code. If the user TABs to see something on main web page the new window goes behind. If the user clicks on the link again the window doesn't come up. Is there any way we can bring the window in front (setfocus) if it already exists ?

remote1 = window.open("","remotewin","width=600,height=135,top=250,left=100");
remote1.location.href = "File1.htm";
if (remote1.opener == null)
remote1.opener = window;
remote1.opener.name = "opener";

Thanks
 
Yes, it's very easy, just use this code:

remote1 = window.open("",eval("'n"+Math.floor(Math.random()*1000)+"'"),"width=600,height=135,top=250,left=100");
remote1.location.href = "File1.htm";
if (remote1.opener == null)
remote1.opener = window;
remote1.opener.name = "opener";



My website:
 
Hello everyone,

I found the tip posted below and it worked great for the part of the code that DKL01 posted. But I couldn't bring the window in front if it already exists by using the code that cyberwolf14 posted. So, how do I bring the new window in front if it already exists and without openning a new window. Here's the problem originally posted:

<< I have a link on my web page. On click, this link opens a new window using following code. If the user TABs to see something on main web page the new window goes behind. If the user clicks on the link again the window doesn't come up. Is there any way we can bring the window in front (setfocus) if it already exists ? >>

Any help would be appreciated. Thanks in advance
 
add to the new window...

<body onClick=&quot;window.focus();&quot;>

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top