Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1624 How can I open a popup window when a visitor clicks a link that leaves my site?

You are here: irt.org | FAQ | JavaScript | Window | Q1624 [ previous next ]

Try:

<html>

<body onLoad="leaving=true" onUnload="if (leaving) window.open('popup.htm','windowName');">

<a href="localLink.htm" onClick="leaving=false">Local link</a>

<a href="http://otherdomain.com/alsoMyLink.htm" onClick="leaving=false">Link on my domain</a>

<a href="http://othersite.com/notMyLink.htm">Link to an external site - popup triggered</a>

also forms can be submitted without the popup:

<form onSubmit="leaving=false">
</form>

</body>

</html>

Feedback on 'Q1624 How can I open a popup window when a visitor clicks a link that leaves my site?'

©2018 Martin Webb