Click to See Complete Forum and Search --> : navigator variable not recognized for IE in some cases


peterpan
01-10-2003, 03:00 AM
I want, from the main window, to lunch another window for the login. If the second window is already opened and I click again from the first window in the login link I just want to change the focus to the second window. It works fine with the following code:

var win=null;
function lunchLogin() {

if(win && !win.closed) win.focus();
else {
newurl = 'https://url_destination; namewin = 'BOL';
win = window.open(newurl,namewin); win.focus();
}
}

The problem comes up when I reload the main page in the first window, then if click over the link of the login the "else" part (so the win.focus(); code) of the statement is executed instead of the "if" part. The problem comes up because when reloading the win variable is set to null again.

Someone suggested me to use "navigator" .So the code was set as following:

function lunchLogin() {

if(navigator.win && !navigator.win.closed) navigator.win.focus();
else {
newurl = 'https://url_destination';
namewin = 'BOL'; navigator.win = window.open(newurl,namewin); navigator.win.focus();
}

This solution works ok for what I asked. But in the next case it doesn't act as wished: I click the login link from the first page. I navigate on the second page/window opened. Then I close the first window. I open a new window (Ctrl + N) with the page containing the login link. I click the login link. Then the focus goes to the already opened window but the else sentence is executed so it goes to the url https://url_destination. It doesn't keep the page where I was after navigating in the window. This happens only for IE (it works as expected for NN)

Any idea?

peterpan
01-10-2003, 06:31 AM
In fact the pop-up window is not a pop-up: it is a new window where I work and navigate within another site

peterpan
01-13-2003, 10:02 AM
Your are right it is not another domain but another subdomain:

window 1, location:

www.name_of_my_site.com

window 2, location:

subdomain.name_of_my_site.com

any solution for this case?

peterpan
01-15-2003, 03:52 AM
You shouldn't focus the problem in the sub-domain. Let's say that the url launched is in the same domain. My problem is:

when I close the first window and then I open a new one with the original url if I click the link executing the lunchLogin() function again, the second window is getting the focus but futhermore (and that is what I don't want) the http://url_destinantion is lunched (so the else sentence is executing!!)

function lunchLogin() {
if(navigator.win && !navigator.win.closed) navigator.win.focus();
else {
newurl = 'http://url_destination';
namewin = 'BOL'; navigator.win = window.open(newurl,namewin); navigator.win.focus();
}

peterpan
01-15-2003, 10:52 AM
Dave, following your example I have this code in page (window) 1:

<HTML>
<HEAD>
<script language="JavaScript">
function lunchLogin() {
win = window.open("",'BOL');
if ( win && !win.closed && win.myBOL) win.focus();
else
{ newurl='http://url_page2_same_domain';
namewin = 'BOL';
win = window.open(newurl,namewin);
win.focus();
}
}
</script>
</HEAD>
<BODY>
<a href="javascript:lunchLogin();">Hi</a>
</BODY>
</HTML>

And the 2nd code in the page opened is:

<HTML>
<HEAD>
<script language="JavaScript">
function createObject() {
myBOL=new Object();
myBOL.name='BOL';
}
</script>
</HEAD>
<BODY onLoad='createObject()'>
<a href="http://www.lotus.com">changing to another site. Lotus, per example</a>
</BODY>
</HTML>

If I click the link in the first window a new window is opened with the url: 'http://url_page2_same_domain'. If then I change the content in the second window to http://www.lotus.com and I click the link in the first page, the focus is set (win.focus()), but also the if sentence is executed (so the 'http://url_page2_same_domain' is lunched in the second window)

I followed the steps you explained in the two examples but ... what is wrong?

peterpan
01-16-2003, 03:35 AM
All???!! And there is no other solution for what I need? (guess my site has more than 300 different framesets and pages!!)