470,815 Members | 2,831 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

Monitoring status of another browser window

Hi

IE6 Win2k

The javascript FAQ describes how you can retain a reference to a window that
you have opened and manipulate the window - focus on it or close it, viz:

4.10 How do I check to see if a childwindow is open, before opening another?
var myWin=null;
function openWin(aURL) {
if (!myWin || myWin.closed ) {
myWin=window.open(aURL,'myWin');
} else{
myWin.location=aURL;
myWin.focus();
}
}

However, javascript variables appear to be reinitialised each time the
browser window
is refreshed so the mechanism described by the FAQ seems to be defeated if
the user refreshes the page.

a) Is it true that javascript variables are reinitiliised when the page is
refreshed?
b) If a) then is there some other way to monitor a child window from another
browser window despite user refreshes?

Thanks
Mike May

Jul 20 '05 #1
2 1667
Mike May wrote:
Hi

IE6 Win2k

The javascript FAQ describes how you can retain a reference to a window that
you have opened and manipulate the window - focus on it or close it, viz:

4.10 How do I check to see if a childwindow is open, before opening another?
var myWin=null;
function openWin(aURL) {
if (!myWin || myWin.closed ) {
myWin=window.open(aURL,'myWin');
} else{
myWin.location=aURL;
myWin.focus();
}
}

However, javascript variables appear to be reinitialised each time the
browser window
is refreshed so the mechanism described by the FAQ seems to be defeated if
the user refreshes the page.
Yep :)
a) Is it true that javascript variables are reinitiliised when the page is
refreshed?
Tis indeed the truth. Easy to test to.

alert(b)
b = "ok, it has a value now"
alert(b)
and then refresh the page......
b) If a) then is there some other way to monitor a child window from another
browser window despite user refreshes?


Use a cookie or sessions.

--
Randy

Jul 20 '05 #2
"Mike May" <ma*@dial.pipex.com> writes:
Hi

IE6 Win2k

The javascript FAQ describes how you can retain a reference to a window that
you have opened and manipulate the window - focus on it or close it, viz:

4.10 How do I check to see if a childwindow is open, before opening another?
var myWin=null;
function openWin(aURL) {
if (!myWin || myWin.closed ) {
myWin=window.open(aURL,'myWin');
} else{
myWin.location=aURL;
myWin.focus();
}
}

However, javascript variables appear to be reinitialised each time the
browser window
is refreshed so the mechanism described by the FAQ seems to be defeated if
the user refreshes the page.

a) Is it true that javascript variables are reinitiliised when the page is
refreshed?
Yes. There is no differene between
b) If a) then is there some other way to monitor a child window from another
browser window despite user refreshes?


Only very trickily.

If you try to open a window again with the same name, and it already
exists, you will be given a new reference to the window. It will probably
also change the content of the window.

If you control the content of the opened window, you can have it keep
check of its parent and write its own reference back to it. That is hard
to time correctly though.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sven Dzepina | last post: by
3 posts views Thread by JSheble | last post: by
3 posts views Thread by Elizabeth Harmon | last post: by
9 posts views Thread by Simon Wigzell | last post: by
19 posts views Thread by Frances | last post: by
11 posts views Thread by The Numerator | last post: by
18 posts views Thread by mistral | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.