Js倒计时代码,当鼠标离开页面与回到页面会自动停止与开始
作者:bea
<title>根据鼠标判断时间:Js倒计时</title> <input type="button" id="downloadbtn" class="meng1an" onclick='if(timeout>0) {alert("停止计时");return false;}document.location="#"; this.disabled=true;'> <script type="text/javascript">
<title>根据鼠标判断时间:Js倒计时</title>
<input type="button" id="downloadbtn" class="meng1an" onclick='if(timeout>0) {alert("停止计时");return false;}document.location="#"; this.disabled=true;'>
<script type="text/javascript">
<!--
var timeCount
var timeout='10';
function countdown()
{
if (timeout <= 0)
{
document.getElementById("downloadbtn").value = '时间到';
if(document.getElementById("downloadfile"))document.getElementById("downloadfile").style.display = '';
}
if (timeout > 0)
{
document.getElementById("downloadbtn").value = '还有 '+timeout+' 秒';
timeCount = setTimeout('countdown()',1000);
}
timeout--;
}
countdown();
document.onmouseover= function(){clearTimeout(timeCount);countdown();}
document.onmouseout= function(){clearTimeout(timeCount);}
-->
</script>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- Javascript 键盘keyCode键码值表
- JQuery与iframe交互实现代码
- jquery 弹出登录窗口实现代码
- 使用jQuery获取radio/checkbox组的值的代码收集
- Jquery 高亮显示文本中重要的关键字
- JQuery 写的个性导航菜单
- JavaScript中出现乱码的处理心得
- js 页面刷新location.reload和location.replace的区别小结
- CSS+Jquery实现页面圆角框方法大全
- HTA版JSMin(省略修饰语若干)基于javascript语言编写
- javascript下arguments,caller,callee,call,apply示例及理解
- 关于Aptana Studio生成自动备份文件的解决办法
- window.js 主要包含了页面的一些操作
- js 效率组装字符串 StringBuffer
- JS+CSS实现的一种交互体验 表单页面
- javascript 仿开心网好友印象功能(点击文字弹出印象框)
- JavaScript 未知高度元素垂直居中实现代码
- 纯CSS实现的当鼠标移上图片添加阴影效果代码
- Div+Js实现的带阴影菜单 微软以前网站曾用过