Forum Moderators: open
I want to use a .js file and keep all of the script off the page. The goal is to not have to add anything to the <body> tag.
Or - can this code be modified to provide an exit pop-up?
</SCRIPT>
<script language="JavaScript">
function mywin2() {
var W1028639942 = window.open('http://www.mysite.com/2nd/myfolder/index.html','winin2');
self.focus();
}
setTimeout("mywin2()",0000);
// -->
</script>
-s-
To include the JS as an external file, copy the entire script less the <script> tags and name the file whatever you like. I usually keep my scripts in a separate directory. Reference them like so in the <head> section:
<sript src="scipts/exitpop.js" language="JavaScript"></script> Any linked JS files will load into the cache, so the functions will be available when needed.
To popup a window on an unload:
<body onUnload="unloadWin(); somethingElseIfNeeded();">
Proper browsers can be set to block such popups, so I guess it's no problem that this method is IE-only ;)
Check [msdn.microsoft.com ] for documentation.
One way to achieve something similar to what I think you are trying to achive would be a pop-under, activated by <snip>. Not that I am advocating such practice, mind you.
Shawn
document.body.onunload = myfunction // attach onunload event
Note the lack of parenthesis on the function -- you are not calling the function, but just setting a reference to the event.
More info [xs4all.nl].