View Full Version : on unload function
I have a (quasi) legitimate reason to use the "on unload function," and now can't find where I was reading about it...
does anyone know where to locate script for it?
newmate
06-23-2002, 02:23 AM
Hi Judy, could give us an idea of what you want to happen with the onunload event handler. It makes a difference what script is used and could also need to include special syntax for cross browser compatibility.:)
Example: If you just want to use the built-in alert box function for Netscape and Explorer to say "Thank you for visiting Regardless Shorthairs" then this anywhere in the body will do it.
<BODY onUnload="alert('Thank you for visiting Regardless Shorthairs')">
Even this doesn't work for other browsers.
Edit: for sp.
window.onunload = fuction() {
alert('Unloading!');
}
Quick example of how to use it.
but I found a script:
http://html_help4u2.tripod.com/dontclik.html
that I think is really neat. When you click on a button, a page comes up that looks like what you see when you're downloading a program (sort of anyway). It says:
"Now downloading virus"
and looks as though something is actually downloading.
I'd like to use it, but I can picture people madly trying to close the window, and leaving my site.
So I want to use "on unload" to take them to a page explaining that it was a joke, with a history (-2) to take them back to the page they came from.
An "on unload" pop-up would be nice, but I don't think I've ever seen one...
Philip M
06-23-2002, 09:12 AM
Good heavens, no. Certainly not. Who could posibly have thought that?
winlineau
06-23-2002, 11:29 AM
<script>
/*
Fair well window launcher script
By JavaScript Kit (http://javascriptkit.com)
Over 200+ free scripts here!
*/
function openpopup(){
//configure "seeyou.htm and the window dimensions as desired
window.open("seeyou.htm","","width=300,height=338")
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie('popped')==''){
openpopup()
document.cookie="popped=yes"
}
}
</script>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.