首页 > 代码库 > 放刷新倒计时
放刷新倒计时
项目中用到的,利用cookie记住防刷新
function getcookie(name) {var cookie_start = document.cookie.indexOf(name);var cookie_end = document.cookie.indexOf(";", cookie_start);return cookie_start == -1 ? ‘‘ : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));}function setcookie(cookieName, cookieValue, seconds, path, domain, secure) {var expires = new Date();expires.setTime(expires.getTime() + seconds);document.cookie = escape(cookieName) + ‘=‘ + escape(cookieValue)+ (expires ? ‘; expires=‘ + expires.toGMTString() : ‘‘)+ (path ? ‘; path=‘ + path : ‘/‘)+ (domain ? ‘; domain=‘ + domain : ‘‘)+ (secure ? ‘; secure‘ : ‘‘);}if (getcookie(‘deftime‘)==‘‘) setcookie(‘deftime‘,60,1000000);var deftime = getcookie(‘deftime‘);function time(obj){ if(deftime == 0){ obj.bind(‘click.myfn‘,function(){ //ajax如果成功执行time(obj)否则出错误提示 time(obj); }).addClass(‘active‘).text(‘重新发送‘); deftime = 60; } else { obj.unbind(‘.myfn‘).removeClass(‘active‘).text(deftime+‘秒后重发‘); deftime--; setcookie(‘deftime‘,deftime,1000000); setTimeout(function(){time(obj)},1000) } }time($(‘.phone-time‘))
放刷新倒计时
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。