1、定义弹出窗口的函数:
function openNewWin(){
window.open ('page.html','newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
}
2、利用setTimeout来10s后执行:
setTimeout('openNewWin()',10000) 10秒后执行yourFunction(),只执行一次
表单的位置大小需要你用CSS设计。以下代码只是实现了你要的弹出功能。
<!DOCTYPE html><html>
<head>
<title>HTML模板</title>
<meta charset="UTF-8"/>
<style type="text/css">
form{
position:absolute
left:100px
top:50px
width:400px
height:300px
border:1px solid #aaaaaa
}
</style>
<script>
var t
function closeForm(){
var form=document.getElementById("form")
form.style.display="none"
}
function showForm(){
var form=document.getElementById("form")
form.style.display="block"
window.clearTimeout(t)
}
function timer(){
t=window.setTimeout(showForm,10000)
}
</script>
</head>
<body onload="timer()">
<form id="form" style="display:none">
<input type="text"/>
<input type="button" value="关闭" onclick="closeForm()"/>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script type="text/javascript">
<!--
var duration=9900
var endTime = new Date().getTime() + duration + 100
function interval()
{
var n=(endTime-new Date().getTime())/1000
if(n<0) return
document.getElementByIdx("timeout").innerHTML = n.toFixed(3)
setTimeout(interval, 10)
}
window.onload=function()
{
setTimeout("window.location.href='http://www.17mm.net'", duration)
interval()
}
//-->
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>等待10秒</title>
</head>
<body>
<form id="form1" runat="server">
<div>
现在剩下 <span id="timeout">10.000</span>秒后将自动跳转</div>
</form>
</body>
</html>