qq_没有美腿的宝马_0
2016-04-17 12:14
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<srtong>操作成功</srtong>
<p><span id="setTimeout">5</span>秒后到主页<a href="#">返回</a></p>
<script type="text/javascript">
var num=5
//获取显示秒数的元素,通过定时器来更改秒数。
function aa(){
document.getElementById("setTimeout").innerHTML=num;
num--;
setTimeout("aa()",1000)
}
//通过window的location和history对象来控制网页的跳转。
</script>
</body>
</html>
好几天没上慕课了,没注意,我改了下
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<srtong>操作成功</srtong>
<div id="setTimeout"><span id="setTimeout1"></span>秒后到主页<a href="#">返回</a></div>
<script type="text/javascript">
var num = 5;
//获取显示秒数的元素,通过定时器来更改秒数。
var add = document.getElementById("setTimeout");
var span1 = document.createElement("span");
function num1() {
if(num>=0){
document.getElementById('setTimeout1').innerHTML = num;
num--;
setTimeout('num1()', 1000);
}else{
return;
}
}
span1.innerHTML = num1();
</script>
</body>
</html>我是先把函数封装起来再调用就好了
<!DOCTYPE html>
<html>
<head>
<title>浏览器对象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先编写好网页布局-->
<p>操作成果</p>
<input id="jishiqi" value="6" type="button" style="border: none;background-color:white; "/><span>秒后回到主页</span><a
href="#" onclick="backBefore();">返回</a>
<script type="text/javascript">
var a = document.getElementById("jishiqi");
function dsq() {
if (a.value > 1) {
a.value = a.value - 1;
}
setTimeout("dsq();", 1000);
}
dsq();
setTimeout("openNewLink();", 5000);
function openNewLink() {
window.open("http://www.baidu.com", '_self');
}
function backBefore() {
window.open(history.back(), '_self');
}
//获取显示秒数的元素,通过定时器来更改秒数。
//通过window的location和history对象来控制网页的跳转。
// function backBefore(){
// }
</script>
</body>
</html>倒数计时我是用input做的
JavaScript进阶篇
469062 学习 · 22582 问题
相似问题