Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Onunload (use with a trigger?!)
07-21-2009, 03:46 PM #1
- Join Date
- Jul 2009
- Thanked 0 Times in 0 Posts
Onunload (use with a trigger?!)
I have a div overlay which presents a survey entry page to users, currently using a timed delay but wanting to add functionality to give the option to load the survey on page exit.
I can get it to load at page exit (using onunload) but a split second later the next page loads and the survey disappears (as its a div overlay and not a popup).
Is there any way I can basically tell the onunload to hold off loading the new page - perhaps waiting for a trigger from the div overlay (saying yes or no to the taking part in the survey?) - So then when you press yes or no it will then load the new page?
07-22-2009, 02:21 AM #2
- Join Date
- Apr 2009
- Thanked 426 Times in 424 Posts
Now that's not very nice, is it? If I were your user, I'd hate you for making me tell you that I don't want to take your survey before you let me leave your site.
Anyway, what you can do is use the unbeforeunload event to show the survey and return false. If you're lucky, the browser will ask the user then if she really wants to leave your site.