首页 > Web开发 > 详细

web 页面上纯js实现按钮倒数功能

时间:2016-01-05 18:42:37      阅读:284      评论:0      收藏:0      [点我收藏+]

需求构思:本功能想实现的是,一个按钮在页面载入就显示提醒续费,,,倒数60秒后,完成提醒功能,可以按另外一个页面跳转到主页。

参考网上的大神,实现如下:Button2倒数,Button3跳转,在页面上添加两个html按钮。

Button2代码 

<input id="Button2" type="button" value="提醒续费倒计时" onclick="return Button2_onclick()" />
        <script type="text/javascript">
var wait=60;
function time(o) {
    if (wait == 0) {
      o.removeAttribute("disabled");
      o.value = "提醒续费倒计时";
      wait = 60;    //设置秒数
    } else {
      o.setAttribute("disabled", true);
      o.value = wait + "提醒续费倒计时";
      wait--;
      setTimeout(function() {
        time(o)
      },
      1000)
           }
           Button3.disabled = false;            //使另外一按钮不可用
  }
  document.getElementById("Button2").onclick = function() { time(this); }

 

Button3代码

 <input id="Button3" type="button" value="button"
            onclick="javascript:window.location.href=‘Default_admin.aspx‘"
            disabled="disabled" />

测试ok。谢谢大神的参考例子

web 页面上纯js实现按钮倒数功能

原文:http://www.cnblogs.com/pyman/p/5103014.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!