頁面定時跳轉的js和php的程式碼實現和頁面定時重新整理
阿新 • • 發佈:2019-02-04
1.meta
<!--5秒鐘後跳轉到指定的頁面-->
<meta http-equiv="refresh" content="5;url=http://www.baidu.com" />
2.winow.location.href=''; 如過頁面重新整理用window.location.reload();
<meta charset=utf-8" />
<title>js定時跳轉頁面的方法</title>
</head>
<body>
<script>
var t=10;//設定跳轉的時間
setInterval("refer()",1000); //啟動1秒定時
function refer(){
if(t==0){
location="http://www.baidu.com"; //#設定跳轉的連結地址
}
document.getElementById('show').innerHTML=""+t+"秒後跳轉到百度"; // 顯示倒計時
t--; // 計數器遞減
//本文轉自:
}
</script>
<span id="show"></span>
</body>
</html>
3.用php的header("location:index.php");//跳轉至主頁
header("refresh:3;url=index.php");//頁面3秒後定時跳轉