JS简易定时器

1、两个html文件,一个是定时程序,另一个在时间到时被打开。
2、MyHtml.html 定时器主程序,运行效果如下:
[img]http://dl.iteye.com/upload/attachment/0066/7781/27a5be9b-8330-3f62-8848-8c6b36cbfa87.png[/img]
其中,文本框内输入多少秒后打开新页面。点 do 按钮开始计时。
代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyHtml.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

</head>

<body>
<form action="" name="form1">
<input type="text" name="miao" style="width: 50px"><input type="button" value="do" onclick="begin()">
</form>
</body>

<script type="text/javascript">
function doone()
{
window.open("show.htm");
}

function begin()
{
var num=form1.miao.value * 1000 ;
setTimeout("doone()",num)
}


</script>
</html>

3、show.htm 在时间点到时被打开,起到提醒作用

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>show.htm</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

</head>

<body>
This time is shoud to get some ... <br>
</body>
</html>


程序见附件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值