js实现定时关闭网页并动态显示时间
[html]
<html>
<head>
<title>title</title>
<script type="text/javascript">
var left = 5;
function show()
{
var showtime = document.getElementById("showtime");
showtime.innerHTML = "此页面将在"+left + "秒后自动关闭页面" ;
left--;
if(left == 0)
{
window.opener=null;
window.close();
}
else
{
setTimeout("show()", 1000);
}
}
</script>
</head>
<body onload="show()">//注意body里的onload属性
<center><div id="showtime"></div></center>
</body>
</html>
<html>
<head>
<title>title</title>
<script type="text/javascript">
var left = 5;
function show()
{
var showtime = document.getElementById("showtime");
showtime.innerHTML = "此页面将在"+left + "秒后自动关闭页面" ;
left--;
if(left == 0)
{
window.opener=null;
window.close();
}
else
{
setTimeout("show()", 1000);
}
}
</script>
</head>
<body onload="show()">//注意body里的onload属性
<center><div id="showtime"></div></center>
</body>
</html>
作者 :wangzihu
补充:web前端 , JavaScript ,