Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm not so good at Javascript and jQuery and i want to addw countdown timer to my web page so i followed the steps mentioned in this link : http://www.1stwebdesigner.com/css/create-coming-soon-page-using-html5-and-css3/[^]
and it works good, but i want to call a function to redirect me to another page after the countdown reached to 0 but i don't know where to add this function, and what function i should call in the javascript file from the jQuery plug-in to handle this issue.
Posted

one way is as sergey said, same approach can be applied if you want to show the count down on your html page:

JavaScript
function countdown(remsec)//remsec in second
{
  if(remsec==-1) //cause it will display until zero
  {
   window.location='the_location_you_want_to_go.html';
   return ;
  }
  delay=remsec*1000;
  $("#div_id_where_you_want_to_show_your_count_down").html(remsec+" Second(s)"); //jquery library
  setTimeout(function(){countdown(remsec-1);}, delay);
}


and call the countdown function from your desired action; as example:
JavaScript
<input type="button" value="download" onclick="countdown(5)" />
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900