confirm alert when visitor hits back

Status
Not open for further replies.

Spades

New member
Mar 19, 2007
660
5
0
Florida
Seems like it would be pretty simple ... don't have much experience with javascript though.

Looking for a script to pop a confirmation alert when a user tries to hit their browsers back button. Basically "Last chance: etc..." click OK to leave and CANCEL to stay.

I have already been using one to pop when a visitor exits but it doesn't apply to the back button.

Anybody have one?
 


maybe this?

Code:
<script language="JavaScript">
  window.onbeforeunload = function() {
    return 'Don\'t leave fucker!';
}
</script>
 
Thanks for trying man, but that'll pop for any method of leaving a page (ie. clicking the aff link.)

What I'm trying to do is pop a confirm box for visitors that hit their back button -- since most visitors like to return to their search rather than close the browser completely.
 
yeah that's true, I guess you could make the affiliate link open a new window, so it would only be a pain in the ass for the user after the converted.
 
Status
Not open for further replies.