Home > General > Affiliate Marketing Forum

How Can I Add Redirect Function In This Countdown Timer Script? THANKS! (3)


10-06-2011 03:33 PM #1 bsb85my (Member)
How Can I Add Redirect Function In This Countdown Timer Script? THANKS!

Hey Guys,
I've found these java codes from somewhere else. Basically I just paste them before </head> in HTML to make it work. Here they are:

Code:
<script language="JavaScript" type="text/javascript">

<!--
var sec = 02;   // set the seconds
var min = 59;   // set the minutes

function countDown() {
   sec--;
  if (sec == -01) {
   sec = 59;
   min = min - 1; }
  else {
   min = min; }

if (sec<=9) { sec = "0" + sec; }

  time = (min<=9 ? "0" + min : min) + " min and " + sec + " sec ";

if (document.getElementById) { document.getElementById('theTime').innerHTML = time; }

SD=window.setTimeout("countDown();", 1000);
if (min == '00' && sec == '00') { sec = "00"; window.clearTimeout(SD); }
}
window.onload = countDown;
// -->
</script>
I was wondering: Let's say when the timer reach 0min 0sec, it will automatically redirect to the offer page. Is there anyone here can help me add the auto-redirect function into the countdown timer script above?


10-06-2011 05:29 PM #2 tijn (Moderator)

change this

Code:
if (min == '00' && sec == '00') { sec = "00"; window.clearTimeout(SD); }
to this

Code:
if (min == '00' && sec == '00') { 
sec = "00"; 
window.clearTimeout(SD); 
window.top.location.href = "http://domain.com";
}


10-06-2011 06:22 PM #3 bsb85my (Member)

Thanks! I'll work it out.


Home > General > Affiliate Marketing Forum