Hi, I would like to add an exit popup window to several pages of a dynamic website. It has a lot of links that point to content in the site. I know that it's possible if you set like onclick='dopopup(), false' on the links that point within the site, so that if the browser is going to any other url the popup comes up. Is it possible to have javascript "listen" or check the url of a clicked link to see if it is pointing outside of the site? Like looking to see if href url is same as site?? I'm trying to avoid having to change all of the href tags on the site as that would be a pain. Any help would be greatly appreciated. If you can provide a script solution I would be willing to pay for it. Thank you.
onload = function(){ var i = 0, aEls = document.getElementsByTagName('a'), l = aEls.length, click = function(){ alert('You are now leaving ' + location.host); }; for ( ; i < l; i++){ if (!aEls[i].href.match(location.host)) aEls[i].addEventListener ? aEls[i].addEventListener("click", click, false) : aEls[i].attachEvent("onclick", click); } }; PHP: Just change the click function to do whatever you want.