navigator variable not recognized for IE in some cases

wxdqz

New Member
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 <!-- m --><a class="postlink" href="https://url_destination">https://url_destination</a><!-- m -->. 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?
 
Back
Top