Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Thanked 0 Times in 0 Posts

    Onunload (use with a trigger?!)

    Hi All,

    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?

    Any ideas?


  • #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.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts