這篇文章主要講解了“HTML頁面跳轉(zhuǎn)的方法有哪些”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“HTML頁面跳轉(zhuǎn)的方法有哪些”吧!
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供天津網(wǎng)站建設(shè)、天津做網(wǎng)站、天津網(wǎng)站設(shè)計(jì)、天津網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、天津企業(yè)網(wǎng)站模板建站服務(wù),10多年天津做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
1) html的實(shí)現(xiàn)
1 2 3 4 5 6 | < head >
<!-- 以下方式只是刷新不跳轉(zhuǎn)到其他頁面 -->
< meta http-equiv="refresh" content="10">
<!-- 以下方式定時(shí)轉(zhuǎn)到其他頁面 -->
< meta http-equiv="refresh" content="5;url=hello.html">
</ head >
|
優(yōu)點(diǎn):簡單
缺點(diǎn):Struts Tiles中無法使用
2) javascript的實(shí)現(xiàn)
1 2 3 4 5 6 | <script language= "javascript" type= "text/javascript" >
// 以下方式直接跳轉(zhuǎn)
window.location.href= 'hello.html' ;
// 以下方式定時(shí)跳轉(zhuǎn)
setTimeout( "javascript:location.href='hello.html'" , 5000);
</script>
|
?點(diǎn):靈活,可以結(jié)合更多的其他功能
缺點(diǎn):受到不同瀏覽器的影響
3) 結(jié)合了倒數(shù)的javascript實(shí)現(xiàn)(IE)
1 2 3 4 5 6 7 8 9 | < span id="totalSecond">5</ span >
< script language="javascript" type="text/javascript">
var second = totalSecond.innerText;
setInterval("redirect()", 1000);
function redirect(){
totalSecond.innerText=--second;
if(second< 0 ) location.href='hello.html';
}
</script>
|
優(yōu)點(diǎn):更人性化
缺點(diǎn):firefox不支持(firefox不支持span、div等的innerText屬性)
3') 結(jié)合了倒數(shù)的javascript實(shí)現(xiàn)(firefox)
1 2 3 4 5 6 7 8 9 | <script language= "javascript" type= "text/javascript" >
var second = document.getElementById( 'totalSecond' ).textContent;
setInterval( "redirect()" , 1000);
function redirect()
{
document.getElementById( 'totalSecond' ).textContent = --second;
if (second < 0) location.href = 'hello.html' ;
}
</script>
|
4) 解決Firefox不支持innerText的問題
1 2 3 4 5 6 7 8 | < span id="totalSecond">5</ span >
< script language="javascript" type="text/javascript">
if(navigator.appName.indexOf("Explorer") > -1){
document.getElementById('totalSecond').innerText = "my text innerText";
} else{
document.getElementById('totalSecond').textContent = "my text textContent";
}
</ script >
|
5) 整合3)和3')
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | < span id="totalSecond">5</ span >
< script language="javascript" type="text/javascript">
var second = document.getElementById('totalSecond').textContent;
if (navigator.appName.indexOf("Explorer") > -1) {
second = document.getElementById('totalSecond').innerText;
} else {
second = document.getElementById('totalSecond').textContent;
}
setInterval("redirect()", 1000);
function redirect() {
if (second < 0 ) {
location.href = 'hello.html';
} else {
if (navigator.appName.indexOf("Explorer") > -1) {
document.getElementById('totalSecond').innerText = second--;
} else {
document.getElementById('totalSecond').textContent = second--;
}
}
}
</ script >
|
感謝各位的閱讀,以上就是“HTML頁面跳轉(zhuǎn)的方法有哪些”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)HTML頁面跳轉(zhuǎn)的方法有哪些這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
網(wǎng)頁標(biāo)題:HTML頁面跳轉(zhuǎn)的方法有哪些
網(wǎng)址分享:http://bm7419.com/article2/gipioc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、Google、微信小程序、動(dòng)態(tài)網(wǎng)站、軟件開發(fā)、App開發(fā)
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源:
創(chuàng)新互聯(lián)