終于寫出來了,調試了半天。。。
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
? <style>
? ? .tips{
? ? ? ? font-size:20px;
? ? ? ? font-weight:bold;
? ? }
? ? .comeback{
? ? ? ? line-height:2em;
? ? }
? ? a{
? ? ? ? margin:0 10px;
? ? }?
? ? ?
? ? ?
? </style>
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <div class="test">
? ? <p class="tips">操作成功</p>
? ? <p class="comeback"><span id="backtime">5</span>秒后回到主頁<a href="#" onclick="GoBack()">返回</a>
? ? </p>
? </div>
??
?
? <script type="text/javascript">??
?
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ? var a=5;
? ? function countDown(){
? ? ? ? document.getElementById("backtime").firstChild.nodeValue=a;
? ? ? ? a--;
? ? ? ? if(a==0){
? ? ? ? ? ? location.assign("http://www.xianlaiwan.cn");
? ? ? ? }
? ? }
? ??
? ? var q =setInterval("countDown()",1000);
? ??
? ? function GoBack() {
? ? ? ? window.history.back();? ??
? ? ? ? }
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?
?</script>?
</body>
</html>
2019-06-19
繼續加油?