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

倒计时关闭提示框
想用javascrpt或者ajax实现一个类似qq的提示倒记时自动关闭,不知道如何把那个时间写到确定按纽上去,倒计时是不是要用timer呀?请各位大大给指点一二,不胜感激

------解决方案--------------------
<html>
<style>
</style>
<script>
var time = 31;//倒计时时间,秒
function timer()
{
if (time > 0)
{
time--;
document.getElementById( "dv ").innerHTML = time;
setTimeout( "timer() ", 1000);
}
else
{
window.close();
}
}
window.onload=function()
{
document.getElementById( "dv ").innerHTML = time;
timer();
}
</script>
<body>
<div id=dv> </div>
<form name=f1 id=f1>

</form>
</body>
</html>
------解决方案--------------------
<INPUT TYPE= "button " id= "tt " value= " "/>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
var time = 60;
function foo()
{
time -= 1;
if (time == 0)
{
document.getElementById( "tt ").value = "OVER ";
alert( "close ");
window.close();
}
else
{
document.getElementById( "tt ").value = "Time left: " + time;
setTimeout(foo, 1000);
}
}
foo();
//-->
</SCRIPT>

like this.
------解决方案--------------------
<input id= "b " type= "button ">
<script>
o = document.getElementById( "b ");
start = 10;
setInterval( "o.value=start-- ",1000);
</script>
------解决方案--------------------
刚才那个没用按钮 <html>
<style>
</style>
<script>
var time = 30;//倒计时时间,秒
function timer()
{
if (time > 0)
{
time--;
document.getElementById( "dv ").innerHTML = time;
setTimeout( "timer() ", 1000);
}
else
{
window.close();
}
}
window.onload=function()
{
document.getElementById( "dv ").innerHTML = time;
}
</script>
<body>
<div id=dv> </div>
<form name=f1 id=f1>
<input type=button value= "关闭 " onclick= "setTimeout( 'timer() ', 1000); ">
</form>
</body>
</html>