Page 1 of 1

Open new broswer window on close

Posted: Thu Sep 18, 2003 6:48 am
by JayBird
Hi,

I am trying to open a new browser window when someone closes to main window of my site. This window logs the user out if they haven't click the LogOut button.

First off i thought this was easy and used the onUnload function to achieve this until i realised that onUnload means the current document that you are viewing on the site. This means that a new window is opened evertime you click a link within the site.

Unfortunately, there is no onClose function in Javascript.

So, how can i open a new window, only when i close the current window.

I have seen it done on online banking sites. The HSBC site does it, but i can't access that at the moment to "borrow" their code. :lol:

Any ideas?

Mark

Posted: Thu Sep 18, 2003 7:56 am
by twigletmac
From the HSBC site, because although I'm useless with JS I do have access to the source of this site :lol:

Code: Select all

<script language="Javascript">
<!--
var doit=true;
function logoff(url) &#123;
    if(doit) &#123;
	    var win;
	    win=window.open(url,win,"scrollbars=no, width=350, height=215, left=80, top=70");
	    win.focus();
	&#125;
&#125;
//-->

</script>
and

Code: Select all

<frameset border="0" frameborder="0" framespacing="0" rows="100%,0\*" onunload="logoff('https://www.ebank.hsbc.co.uk/servlet/com.hsbc.ib.app.pib.cp.Logoff?success=/main/logoff.jsp&error=/main/gensorry.jsp');" >
	<frame frameborder="0" framespacing="0" marginheight="0" marginwidth="0" scrolling="no" name="master" noresize src='https://www.ebank.hsbc.co.uk/welcomebackindex.jsp' />
</frameset>
Mac

Posted: Thu Sep 18, 2003 8:12 am
by JayBird
ah, i see, they use frames to get around the problem of the new window opening even when you navigate to a new page within the site.

Clever.... :)

Mark

Posted: Thu Sep 18, 2003 9:14 am
by JayBird
Are there any other ways to achieve this without using frames?

Mark