lkeane
09-14-2005, 04:43 AM
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 am using JavaScriptKit's FairWell window launcher (http://www.javascriptkit.com/script/cut65.shtml):
<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>
with <body onunload="loadpopup()">
Any ideas on how to exclude my domain?
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 am using JavaScriptKit's FairWell window launcher (http://www.javascriptkit.com/script/cut65.shtml):
<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>
with <body onunload="loadpopup()">
Any ideas on how to exclude my domain?