is it possible to have the exit page only load if they exit at the moment it loads even if the user clicks a link to load another page the exit page still comes up.. I only want it to come up if they exit full stop, if they click on a link from my page i dont want the exit page to load....is that possible??
<script>
<!--
not_leaving=0
function goodbye(){
if(not_leaving==1){
return
}
open("yourpage"); <!--Place your path and file name here-->
}
// -->
</script>
The above script would have to go in every page then include
J, I don't think that would work. I would pass a variable to the function like this:
<script type="text/javascript">
<!--
var not_leaving=0;
function goodbye(not_leaving){
if(not_leaving==1){return;}
window.open("yourpage"); //Place your path and file name here
}
// -->
</script>
If you have many links on the page, you may want to use JavaScript to populate their onClick functions dynamically. (E.g., a for() loop to go through all of the links on the page and set their onClick functions to goodbye(1);.)
[J]ona
Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.
Older days, this would be another site I wouldn't want to visit. But now, I am equipped with Opera. Throw all the popups you want, world! I am ready for you!!
Jona, I think that you may be confusing scope of the variable not_leaving. I don't know javascript much, but based on my programming knowledge, for the function
function goodbye(not_leaving)
scope of this not_leaving variable is limited to the function... this variable is different from the external variable defined as not_leaving=0;
You may have function
goodbye(not_leaving) {
if(not_leaving) { return;}
window.open("popup.html");
}
Note that onclick, you'll call goodbye(1)...
But will browser execute this function twice - once onclick and next onunload? If it does, this method wont work.
Originally posted by nkaisare Older days, this would be another site I wouldn't want to visit. But now, I am equipped with Opera. Throw all the popups you want, world! I am ready for you!!
I agree with you. I never make use of popups unless, for example, there is a need for it. But 99% of the time, I go with something else.
Originally posted by nkaisare Jona, I think that you may be confusing scope of the variable not_leaving. I don't know javascript much, but based on my programming knowledge, for the function
function goodbye(not_leaving)
scope of this not_leaving variable is limited to the function... this variable is different from the external variable defined as not_leaving=0;
That is incorrect. What I have done is set not_leaving as a global variable, with a value of zero. When you click a link, it will set not_leaving to 1, thus returning the function and stopping before it goes on to opening a new window. Although, I did forget to mention the slight change in the onUnload function:
<body onUnLoad="goodbye(0);">
[J]ona
Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.
Originally posted by Jona
<body onUnLoad="goodbye(0);">
In which case, you do not need to pre-define it as a global variable.
BTW, when one clicks a link, and there are onclick and onunload event handlers, wouldn't both of them be called? In that case, onclick will not cause a popup, but onunload will.
I guess you should not pass not_leaving as a variable to the function; instead you should have
<a onclick="not_leaving=1; goodbye()">...
Bookmarks