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

Popup Object

Status
Not open for further replies.

vbkris

Programmer
Jan 20, 2003
5,994
IN
hi guys,

I have code like this:

window.open('somePage','myWin','features');


the above script is emitted by a DLL (using ASP.NET).

i cannot control how it emits that code.

now i want to check whether the popup has opened. if you notice above, no variable has been assigned to the popup.

is there any way i can detect wether a popup named 'myWin' is open currently other than going the variable way?

alternative that i have is:

theWin=window.open('somePage','myWin','features');

if(theWin)
{
//do code here
}


but implementing the above will take huge time as i have to recreate a new DLL and apply the same throughout...

Known is handfull, Unknown is worldfull
 
With the popup window's name, to establish a local handle of it, one can do it like this.
[tt]
window.open("page_1_thisDomain.html","myWin");
//etc etc
//and at some later stage in the same function or elsewhere
var swinname="myWin"; //suppose this knowledge is retained
//A local handle of the popup will be established.
[blue]var owin_local=window.open("",swinname);[/blue]

//Establish the evidence you get the same popup handle
//[1] This shows evidence #1
//This will succeed as long as you are in the thisDomain
//Cross-domain query .location will fail
alert(owin_local.location);
//[2] This shows evidence #2
//Re-direction will succeed as long as in thisDomain.
//Again cross-domain will fail, permission denied.
owin_local.location.href="page_2_thisDomain.html";
[/tt]
 
vbkris,

the only way to do this, afaik, is to assign it to a variable.

you can then do a test like this:

Code:
var theWin = window.open(...);
if ( theWin && !theWin.closed ) {
   ...
}

to see if it was a window and is still open...



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
I meant to show the way to re-establish that handle. May be I fail...
 
hi guys,

guess i have to assing that variable. thanks for your help...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top