倒数计时器jQuery后调用函数 [英] Calling function after countdown timer jQuery

查看:70
本文介绍了倒数计时器jQuery后调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是很擅长Javascript和jQuery,我想把倒数计时器添加到我的网页,所以我按照这个链接中提到的步骤进行操作: http://www.1stwebdesigner.com/css/create-coming-soon-page -using-html5-and-css3 / [ ^ ]

它运行良好,但是我想在倒计时达到0之后调用一个函数将我重定向到另一个页面但是我我不知道在哪里添加这个函数,以及我应该在jQuery插件的javascript文件中调用什么函数来处理这个问题。

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.

推荐答案

已回答这里: http://stackoverflow.com/questions/7276677/jquery-redirect-到URL的后指定的时间 [<一个href =http://stackoverflow.com/questions/7276677/jquery-redirect-to-url-after-specified-timetarget =_ blanktitle =New Window> ^ ]。br />


-SA
Answered here: http://stackoverflow.com/questions/7276677/jquery-redirect-to-url-after-specified-time[^].

—SA


一种方式如sergey所说,如果你想要同样的方法可以应用在你的html页面上显示倒计时:



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

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);
}
("#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:

<input type="button" value="download" onclick="countdown(5)" />


这篇关于倒数计时器jQuery后调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆