[Javascript] Alert user when leaving site - Simplified
Triche Osborne
wdlists at triche-osborne.com
Sat Sep 10 17:26:29 CDT 2005
The non-automated version would look like this:
JS (linked or in page HEAD):
function sayGoodbye(domainName)
{
if(window.location.hostname != domainName)
{
alert("B'Bye!");
}
}
Link structure:
<a href="http://www.whatever.com"
onclick="sayGoodbye(this.hostname);">Link Text</a>
If you like, you can add the onclick event only to outgoing links.
However, if you choose to automate the attachment of the onclick event
through an onload function, the function is set up to perform only for
outgoing links, so it won't matter that the onclick gets attached to
every link.
Triche
More information about the Javascript
mailing list