日期:2014-05-16  浏览次数:20413 次

用javascript怎么实现一个到计时器
用javascript怎样实现到计时这个功能啊?
我想让用户在也面停留35秒才能离开页面,这个怎么实现?

------解决方案--------------------
<input id= "btn " type= "button " value= " " disabled>
<script>
var count = 10;
function setButton()
{
var btn = document.getElementById( "btn ");
if(count == 0)
{
btn.disabled = false;
btn.value= "同意 ";
}
else
{
btn.value= "同意( "+count+ ") ";
count--;
window.setTimeout(setButton, 1000);
}
}
setButton();
</script>