Delayed Exit Splash Javascript

by 8 replies
11
On one of my download page - Instead of a download link, I have set a redirection code for the download:
So when an user landed on that page, it pops up the download request straightaway.

The problem is that, I also have the exit popup - exitsplash codes installed on that page. Therefore when the download redirect executes, the exit popup pops up....

And this is not what I want.

So I was thinking if it's possible to delay the exit popup script to like 3seconds/5seconds, so that it runs the script after the user has downloaded the file already?




I have found this solution:
But it doesn't seem to be working....


Any ideas?
#programming #delayed #exit #javascript #splash
  • If that is all of the Javascript code for the exit popup, then you are missing a few things. Try this instead:

    Put this in the <head> section...
    HTML Code:
    <meta http-equiv="refresh" content="0;url=http://www.YourZipFile.zip"> 
    <script type="text/javascript">
    <!--
    function exitPopup() {
        var answer = confirm("***************  BEFORE YOU GO!  *************** nn Click the 'OK' button for something very special! nn Or click the 'Cancel' button if you're not interested.");
        if (answer){ /* If OK button was clicked */
            window.location = "http://www.SpecialOfferPage.com";
        }
    }
    //-->
    </script>
    Don't forget to change the 'YourZipFile' and 'SpecialOfferPage' above to the correct URL's. Also, it appears that the forum has stripped out the backslashes in the above code, so in the 2 places where you see nn, it needs to be replaced with \n\n

    Then use this for the opening 'Body' tag...
    HTML Code:
    <body onload="setTimeout(function(){exitPopup()},5000);">
    That's set to a 5 second delay for the exit popup. If you want a different delay time, then change '5000' (milliseconds) to something else. But the exact timing won't be very important, because the 'download file' popup will hide the exit popup at first.
    • [2] replies
    • Good call Ed.

      Also stop using exitSplash, that script didn't work very well with IE (unless there was an update i am unaware of)

      I am also a big fan of displaying a hidden div (and hiding what ever content was on the page) in leu of a redirect.
      • [1] reply
    • For some reason, the exit pop up code:
      still execute even the user is still on the page...

      I have deleted the meta redirection code for testing, the exit code still pops up no matter what O_O..
  • Bump, anyone please? need it urgent!
    • [1] reply
    • Ed,

      I thought you wanted the popup to appear after the user has been on the page for X seconds, which is exactly what the code I provided does.

      If you want the popup to appear when the user tries to leave the page, on the other hand, then you can make a popup appear then... BUT if you do it that way (example here), then you will not be able to redirect them to a different URL (the only options would be 'leave site' or 'stay on current page'). As far as I know, there is no way around this, as it's a security feature on all modern browsers.

      So your options are to use a time-based popup, which gives you the ability to redirect to a different URL. Or you can use a popup that detects when the user is trying to leave, but you will not have the ability to redirect them to a different URL in that case.
  • Oh ok, thank you so much for your help, and advises Brandon.
    This is why I love the community!
    • [1] reply
    • I am using this one on my wordpress inside the post and its working for me. I use it with my squeeze pages. Please change this howto.harrybhanot.com/localsniperjv/ with your site.

      <SCRIPT LANGUAGE="JavaScript"> var cookie="qspVF8JC"; var exit=true; var filename='http://howto.harrybhanot.com/localsniperjv/'; var popup; var height="+screen.height+"; var width="+screen.width+"; var left=(screen.width/2)-("+screen.width+"/2); var top=(screen.height/2)-("+screen.height+"/2); function exitpop(){ if(exit){ if (getcookie(cookie)==""){ popup = window.open(filename, "","height="+height+",width="+width+",top="+top+", left="+left+",location=yes,menubar=yes,resizable=y es,scrollbars=yes,status=yes,titlebar=yes,toolbar= yes,directories=yes"); setcookie(); } } } function getcookie(cookieName) { var id = cookieName + "="; var cookievalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(id); if (offset != -1) { cookievalue = "x"; } } return cookievalue; } function setcookie () { var today = new Date(); var expdate = new Date(today.getTime() + 1 * 24 * 60 * 60 * 1000); document.cookie = cookie + "=" + escape ("done")+ ";expires=" + expdate.toGMTString(); } document.onunload=exitpop; window.onunload=exitpop; </SCRIPT>

Next Topics on Trending Feed

  • 11

    On one of my download page - Instead of a download link, I have set a redirection code for the download: <meta http-equiv="refresh" content="0;url=http://www.URL.com/file.zip"> So when an user landed on that page, it pops up the download request straightaway.