Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Delayed Exit Splash Javascript (https://www.warriorforum.com/programming/671630-delayed-exit-splash-javascript.html)

Ed Micah 11th September 2012 07:17 AM

Delayed Exit Splash Javascript
 
On one of my download page - Instead of a download link, I have set a redirection code for the download:
Quote:

<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:
Quote:

<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?

Brandon Tanner 11th September 2012 12:29 PM

Re: Delayed Exit Splash Javascript
 
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.

kevinclanton 11th September 2012 01:10 PM

Re: Delayed Exit Splash Javascript
 
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.

Ed Micah 11th September 2012 05:43 PM

Re: Delayed Exit Splash Javascript
 
Quote:

Originally Posted by Brandon Tanner (Post 6964683)
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.

Quote:

Originally Posted by kevinclanton (Post 6964914)
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?

Ed Micah 11th September 2012 05:57 PM

Re: Delayed Exit Splash Javascript
 
For some reason, the exit pop up code:
Quote:

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

Ed Micah 12th September 2012 01:35 AM

Re: Delayed Exit Splash Javascript
 
Bump, anyone please? need it urgent!

Brandon Tanner 12th September 2012 11:06 AM

Re: Delayed Exit Splash Javascript
 
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.

Ed Micah 12th September 2012 06:43 PM

Re: Delayed Exit Splash Javascript
 
Oh ok, thank you so much for your help, and advises Brandon.
This is why I love the community! :D

hbhanot 17th December 2012 11:33 AM

Re: Delayed Exit Splash Javascript
 
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>


All times are GMT -6. The time now is 08:14 AM.