HTML實(shí)現(xiàn)頁面自動(dòng)跳轉(zhuǎn)的方法有哪些(實(shí)例)
本文是百分網(wǎng)小編搜索整理的五個(gè)實(shí)例給大家介紹html如何實(shí)現(xiàn)頁面自動(dòng)跳轉(zhuǎn),感興趣的朋友一起學(xué)習(xí)吧!!想了解更多相關(guān)信息請(qǐng)持續(xù)關(guān)注我們應(yīng)屆畢業(yè)生考試網(wǎng)!
1)html的實(shí)現(xiàn)
代碼如下:
<head>
<meta http-equiv="refresh" content="5;url=hello.html">
</head>
優(yōu)點(diǎn):簡(jiǎn)單
缺點(diǎn):Struts Tiles中無法使用
2)javascript的實(shí)現(xiàn)
代碼如下:
<mce:script language="javascript" type="text/javascript"><!--
setTimeout("javascript:location.href='http://liting6680.blog.163.com/blog/hello.html'", 5000);
// --></mce:script>
優(yōu)點(diǎn):靈活,可以結(jié)合更多的其他功能
缺點(diǎn):受到不同瀏覽器的影響
3)結(jié)合了倒數(shù)的javascript實(shí)現(xiàn)(IE)
代碼如下:
<span id="totalSecond">5</span>
<mce:script language="javascript" type="text/javascript"><!--
var second = totalSecond.innerText;
setInterval("redirect()", 1000);
function redirect(){
totalSecond.innerText=--second;
if(second<0) location.href='http://liting6680.blog.163.com/blog/hello.html';
}
// --></mce:script>
優(yōu)點(diǎn):更人性化
缺點(diǎn):firefox不支持(firefox不支持span、p等的.innerText屬性)
3 )結(jié)合了倒數(shù)的javascript實(shí)現(xiàn)(firefox)
代碼如下:
<mce: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='http://liting6680.blog.163.com/blog/hello.html';
}
// --></mce:script>
4)解決Firefox不支持innerText的問題
代碼如下:
<span id="totalSecond">5</span>
<mce: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";
}
// --></mce:script>
5)整合3)和3')
代碼如下:
<span id="totalSecond">5</span>
<mce: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='http://liting6680.blog.163.com/blog/hello.html';
} else
{
if (navigator.appName.indexOf("Explorer") > -1)
{
document.getElementById('totalSecond').innerText = second--;
} else
{
document.getElementById('totalSecond').textContent = second--;
}
}
}
// --></mce:script>
【HTML實(shí)現(xiàn)頁面自動(dòng)跳轉(zhuǎn)的方法有哪些(實(shí)例)】相關(guān)文章:
java servlet頁面跳轉(zhuǎn)的方法10-03
PHP頁面跳轉(zhuǎn)的技巧09-20
PHP頁面跳轉(zhuǎn)到另一個(gè)頁面的方法09-22
Dreamweaver跳轉(zhuǎn)菜單的方法技巧介紹08-03
用PHP自動(dòng)把純文本轉(zhuǎn)換成Web頁面方法09-02
php抓取頁面的的方法09-02
php抓取頁面的方法09-23