求一段访问页面有时间限制的Javascript 简单是简单,但是对于一个没写过javascript的人来说,花时间去学习再写成本太高啊。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档 </title> <script type="text/JavaScript"> var stingTime; var timeLeft = 10 ; function countTime() { document.getElementById("hehe").disabled=true; if(timeLeft == 0) { //alert("时间到!"); location.href="http://www.baidu.com"; return; } document.getElementById("timeDiv").innerHTML = "剩余时间:" + timeLeft + "秒"; timeLeft = timeLeft - 1; setTimeout('countTime()',1000); } </script> </head> <body> <input type='button' value='开始考试' onclick='countTime();' id='hehe'><div id='timeDiv'></div> </body> </html> 呵呵,3楼主要是用的setTimeout('countTime()',1000); 我再提一个方法,在进入的JSP页写个自动跳转呵呵~没有3楼的好,而且倒计时得另外处理 jQuery Tab 如何自动切换啊? 用session实现用户登录和注销的问题 头部调用的JS文件能否在页面显示完成后再加载? setInterval嵌套在一个方法里的时候出现的问题 怎样用eval()向div中插入数据?? 怎么改 :跳转到相应页 导航栏文字的背景色就变成蓝色 大家帮我看看这段javascript的代码是怎么错了,真让我焦头烂额???? 如何用button实现链接功能(不用form和window.open)? 请教高手:如何禁止网页里的文本选择? 怎样用js修改div里标签的样式 如何做出点击图片,图片居中,其他部分阴影显示 js字符串拼接与替换
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
<script type="text/JavaScript"> var stingTime;
var timeLeft = 10 ;
function countTime()
{
document.getElementById("hehe").disabled=true; if(timeLeft == 0)
{
//alert("时间到!");
location.href="http://www.baidu.com";
return;
}
document.getElementById("timeDiv").innerHTML = "剩余时间:" + timeLeft + "秒";
timeLeft = timeLeft - 1;
setTimeout('countTime()',1000);
} </script> </head>
<body>
<input type='button' value='开始考试' onclick='countTime();' id='hehe'>
<div id='timeDiv'></div>
</body> </html>