一些頁面自動(dòng)跳轉(zhuǎn)的實(shí)現(xiàn) 功能:5秒后,自動(dòng)跳轉(zhuǎn)到同目錄下的02view.html文件 1)html的實(shí)現(xiàn) < head > < meta http-equiv ="refresh" content ="5;url=02view.html" > </ head > 優(yōu)點(diǎn):簡(jiǎn)單 缺點(diǎn):Struts Tiles中無法使用 2)javascript的實(shí)現(xiàn) < script language ="javascript" type ="text/javascript" > setTimeout( " javascript:location.href='02view.html' " , 5000 ); </ script > 優(yōu)點(diǎn):靈活,可以結(jié)合更多的其他功能 缺點(diǎn):受到不同瀏覽器的影響 3)結(jié)合了倒數(shù)的javascript實(shí)現(xiàn)(IE) < 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 = '02view.html'; } </ script > 優(yōu)點(diǎn):更人性化 缺點(diǎn):firefox不支持(firefox不支持span、div等的innerText屬性) 3')結(jié)合了倒數(shù)的javascript實(shí)現(xiàn)(firefox) < 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 = '02view.html'; } </ script > 4)解決Firefox不支持innerText的問題 < span id ="totalSecond" > 5 </ span > < script language ="javascript" type ="text/javascript" > if (navigator.appName.indexOf( " Explorer " ) > - 1 ){ document.getElementById('totalSecond').innerText = " mytextinnerText " ; } else { document.getElementById('totalSecond').textContent = " mytexttextContent " ; } </ script > 5)整合3)和3') < 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 = '02view.html'; } else { if (navigator.appName.indexOf( " Explorer " ) > - 1 ) { document.getElementById('totalSecond').innerText = second -- ; } else { document.getElementById('totalSecond').textContent = second -- ; } } } </ script > 一些頁面自動(dòng)跳轉(zhuǎn)的實(shí)現(xiàn) 更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主 微信掃碼或搜索:z360901061 微信掃一掃加我為好友 QQ號(hào)聯(lián)系: 360901061 您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。 【本文對(duì)您有幫助就好】元 2元 5元 10元 20元 自定義 喜歡作者