...

View Full Version : check if window is open without using window.closed



alphanumeric
01-19-2003, 01:13 AM
Hi,

i´ve a problem. I want to check whether a (pop-Up)window is open or not. I can't use winname.closed, because if the window was not opend yet or was opend by an other page i get an error (winname.closed is not an object). Is there a way to realy check if a window is open and not only check if the window was closed by the user as "winname.closed" does.

Marc

justame
01-19-2003, 01:35 AM
alp...
fpmc just a nother® forum member posted this just a wayyy® back...(copied/credited/saved from October 7, 1999 8:28:31 AM) hehehe...


<Script language="JavaScript">
function openN(URL,winname,ATTR) {
if (window.winN && !winN.closed) winN.location = URL;
else winN = open(URL,winname,ATTR);
winN.focus();
}
</Script>

Instead of using window.open(), one will use:
window.openN(URL, "win", "width=400...")

In the entire page, any links that uses window.openN() will always open in one window.

Just for SonicT. If you want the window always to have the name "win", then

<Script language="JavaScript">
function openN(URL,ATTR) {
if (window.winN && !winN.closed) winN.location = URL;
else winN = open(URL,"win",ATTR);
winN.focus();
}
</Script>

To call it:
window.openN(URL, Attributes)


just a goodluck® n' hope it helps ya...:O)))

alphanumeric
01-19-2003, 10:33 AM
Hi,

sorry, thats not what I need. I'll try to explain it.
I want to build a "file-download-system". In the new window i'm using JavaScript to create a list with every file a user has selected (on my whole page)to download them all together. This is why i can't use window.open() more then one time, because a second window.open() will reload the new window and destroy the whole list. this is why i have to know whether the downloader-window is already open or not.

Marc

Algorithm
01-19-2003, 10:46 PM
var fileListWin = null;

function openFileList(){
if(fileListWin==null || fileListWin.closed){
fileListWin = window.open();
} else {
fileListWin.focus();
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum