跳轉(zhuǎn)頁面的方法:1、html中可以利用meta標(biāo)簽進行跳轉(zhuǎn),語法“”;2、javascript中可以利用location對象的href屬性進行跳轉(zhuǎn),語法“window.location.href=頁面地址”。
本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。
html/JavaScript實現(xiàn)頁面跳轉(zhuǎn)
1、html中使用meta中跳轉(zhuǎn),通過meta可以設(shè)置跳轉(zhuǎn)時間和頁面
<head> <!--只是刷新不跳轉(zhuǎn)到其他頁面 --> <meta http-equiv="refresh" content="5"> <!--定時轉(zhuǎn)到其他頁面 --> <meta http-equiv="refresh" content="5;url=index.html"> </head>
2、通過javascript中實現(xiàn)跳轉(zhuǎn)
1 // 直接跳轉(zhuǎn) 2 window.location.href='index.html'; 3 // 定時跳轉(zhuǎn) 4 setTimeout("javascript:location.href='index.html'", 5000);
html跳轉(zhuǎn)上一頁的方式
window.history.go(-1);或者window.history.back(-1);
<script type="text/javascript"> var wrong = document.getElementById('btn'); wrong.onclick = function() { window.history.go(-1);//返回上一頁 window.history.back(-1);//返回上一頁 } </script>
在html中寫
<a href=”#” onClick=”JavaScript :history.back(1);”>返回上一頁</a> <a href=”#” onClick=”javascript :history.Go(-1);”>返回上一頁</a>
【推薦學(xué)習(xí):javascript高級教程】