I am trying to launch a popup window when someone exits my site (as in when they press 'home' in their browser). I do not want the popup to launch when they click on an internal link.
I was able to get a simple script to work using 'onUnload'. The problem is that it opens a popup when the navigation menu is clicked (a link to another page on my site).
I wanted to exclude my domain from the onUnload function. Is this possible?
I think I want to combine this
and thisCode:<script language="javascript"> /* Auto center window script- Eric King (http://redrival.com/eak/index.shtml) Permission granted to Dynamic Drive to feature script in archive For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com */ var win = null; function NewWindow(mypage,myname,w,h,scroll){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable' win = window.open(mypage,myname,settings) } </script>
with thisCode:<BODY onUnload="NewWindow('http://yahoo.com','name','400','400','yes');return false">
Does anyone know how to combine these? If you know of a better way to launch a site exit message, please tell me (btw, this is not an ad, it is a epilogue-type message like "Thanks for visiting" or similar)Code:<script language="JavaScript1.2"> <!-- //Open offsite links in new window option- By Jessica Hammer //Heavily modified by Dynamic Drive //Visit http://www.dynamicdrive.com for this script //1)Enter domains to be EXCLUDED from opening in new window: var excludedomains=["dynamicdrive.com", "javascriptkit.com"] //2)Automatically open offsite links in new window? (1=yes, 0 will render a checkbox for manual selection) var auto=1 var excludedomains=excludedomains.join("|") rexcludedomains=new RegExp(excludedomains, "i") if (!auto) document.write('<form name="targetmain"><input type="checkbox" name="targetnew" checked onClick="dynamiclink()">Open off-site links in new window</form>') function dynamiclink(){ if (auto||(!auto&&document.targetmain.targetnew.checked)){ for (i=0; i<=(document.links.length-1); i++) { if (document.links[i].hostname.search(rexcludedomains)==-1&&document.links[i].href.indexOf("http:")!=-1) document.links[i].target="_blank" } } else for (i=0; i<=(document.links.length-1); i++) { if (document.links[i].hostname.indexOf(mydomain)==-1) document.links[i].target="" } } if (auto) window.onload=dynamiclink // --> </script>



Reply With Quote
. I'm really sorry but what do I need to edit? Thanks again for your help.
So we are popping a usibility survey, let's say the popup url is 
Bookmarks