1、html中使用meta中跳轉,通過meta可以設置跳轉時間和頁面
<head> <!--只是刷新不跳轉到其他頁面 --> <meta http-equiv="refresh" content="5"> <!--定時轉到其他頁面 --> <meta http-equiv="refresh" content="5;url=index.html"> </head>
2、通過javascript中實現跳轉
1 // 直接跳轉 2 window.location.href='index.html'; 3 // 定時跳轉 4 setTimeout("javascript:location.href='index.html'", 5000);
3、html跳轉上一頁的方式
window.history.go(-1);或者window.history.back(-1);
1 <script type="text/javascript"> 2 var wrong = document.getElementById('btn'); 3 wrong.onclick = function() { 4 window.history.go(-1);//返回上一頁 5 window.history.back(-1);//返回上一頁 6 } 7 </script>
在html中寫
<a href=”#” onClick=”JavaScript :history.back(1);”>返回上一頁</a> <a href=”#” onClick=”javascript :history.Go(-1);”>返回上一頁</a>
在Js中網頁跳轉的寫法
1、window.location.href
1 window.location.href="http://www.baidu.com"; //在原有窗口打開
2.window.navigate方式跳轉
1 window.navigate("http://www.baidu.com");
1 function toBooks() { 2 3 //在原有窗口打開 4 window.location.href = "http://www.baidu.com"; 5 //打開新的窗口 6 window.open("http://www.baidu.com"); 7 }
直接跳轉加參數
<script language="javascript" type="text/javascript"> window.location.href="login.jsp?backurl="+window.location.href; </script>