[Javascript] Another popup question

Hassan Schroeder hassan at webtuitive.com
Wed Sep 18 09:32:56 CDT 2002


Gavin Cheyne wrote:

> I've been asked alter a javascript popup so that it triggers when a user
> leaves a particular area of the site. This will have to be triggered by
> onUnload so that it appears even if the user jumps to another site.

> My question is this: can I grab the url that the browser is going to, rather
> than the one its coming from?

You can *if* the user is leaving via a link on your page --

<script type="text/javascript">
function inform(e)
{
	alert(e.target.parentNode.href);
}
document.onclick=inform;
</script>
</head>
<body>
Next I'm going to <a href="here.html">here</a>
</body>

If they leave by typing something in the address bar, you won't
know where they're going, but your onunload routine can at least
determine that the unload wasn't preceded by an onclick event.

HTH!
-- 
H*
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

     -- creating dynamic Web sites and applications since 1994 --





More information about the Javascript mailing list