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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

an interesting Q on popup window

Status
Not open for further replies.

WhiteSox

Programmer
May 22, 2001
20
US

in page 1, i have a sentense
<a href=&quot;javascript:window.open(url, '')&quot;>
every time i click this link, it will pop up a new window.

what i want to see is:
the first time i click it, it pops up a new window. for the second time, it doesn't pup up another new window. instead, it uses the existing window for following pop up, unless the first popup window is closed.

any idea?
 
you can use the windows.closed property which returns a boolean to check if the first pop up window is closed before opening up the new pop up. Something like this should work:

if (newPopUpwin.closed)
{
anotherpopup=window.open(url, '');
}
else
{
alert(&quot;some error message&quot;)
}

hope this helps

;-)
 
I think you will find that you can name the window you open with the second parameter in your command.
<a href=&quot;javascript:window.open(url, ' WindowName')&quot;>
this means that if there is not a window with that name a new one will be created....if one already exists, it will be the target of the url.

hope that helps


Bassguy
 
i found how to solve this problem. see the window.open() syntax:

oNewWindow = window.open( [sURL] [, sName] [, sFeatures] [, bReplace])

set the last parameter 'bReplace' to false. it will guarantee the new page shows up in previously opened window.

for further info, please refer to
 
hie WhiteSox, i usually do it like bussguy told:
wnd=window.open(url,'name',prefs), w/o any replaces (i gues replace wont work everywhere)
so, when i wanna open the next file in the window that i have already opened, i just use the same name, & if i dont wanna do so - i use dfrnt names..
clear? regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top