Delayed Exit Splash Javascript

8 replies
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.

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:
<script type="text/javascript">
function Func1()
{

var exitsplashalertmessage = '***************************************\n\n > > > W A I T < < <\n\n CLICK THE ***CANCEL*** BUTTON\n on the NEXT Window for Something\n VERY Special!\n\n************************************** *';
var exitsplashmessage = '***************************************\n\n W A I T B E F O R E Y O U G O !\n\n CLICK THE *CANCEL* BUTTON RIGHT NOW\n TO STAY ON THE CURRENT PAGE.\n\n I HAVE SOMETHING VERY SPECIAL FOR YOU!\n\n***************************************';
var exitsplashpage = 'http://www.url.com';

}
function Func1Delay()
{
setTimeout("Func1()", 1000);
}
</script>
But it doesn't seem to be working....


Any ideas?
#delayed #exit #javascript #splash
  • Profile picture of the author Brandon Tanner
    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.
    Signature

    {{ DiscussionBoard.errors[6964683].message }}
    • Profile picture of the author kevinclanton
      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.
      {{ DiscussionBoard.errors[6964914].message }}
      • Profile picture of the author Ed Micah
        Originally Posted by Brandon Tanner View Post

        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 nn

        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.
        Originally Posted by kevinclanton View Post

        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.
        Thank you so much for the tips on helping me make it work.
        Yes, it was missing a line of code which was the line that calls the exitsplash.php

        But I think I will try yours after this, since Kevin has mentioned that Exitsplash doesn't work properly on IEs....

        And one thing I don't really understand is that, what do you mean by " But the exact timing won't be very important, because the 'download file' popup will hide the exit popup at first."??

        I thought the purpose was to execute the exit popup script after the meta redirect has executed?
        {{ DiscussionBoard.errors[6966393].message }}
    • Profile picture of the author Ed Micah
      For some reason, the exit pop up code:
      <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>
      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..
      {{ DiscussionBoard.errors[6966464].message }}
  • Profile picture of the author Ed Micah
    Bump, anyone please? need it urgent!
    {{ DiscussionBoard.errors[6968211].message }}
    • Profile picture of the author Brandon Tanner
      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.
      Signature

      {{ DiscussionBoard.errors[6970972].message }}
  • Profile picture of the author Ed Micah
    Oh ok, thank you so much for your help, and advises Brandon.
    This is why I love the community!
    {{ DiscussionBoard.errors[6973353].message }}
    • Profile picture of the author hbhanot
      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>
      {{ DiscussionBoard.errors[7488153].message }}

Trending Topics