404页面 3秒后跳到首页 实现
生活随笔
收集整理的這篇文章主要介紹了
404页面 3秒后跳到首页 实现
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
---恢復(fù)內(nèi)容開始---
當(dāng)我們訪問一個頁面不存在的時候,就會跳到404頁面
一般網(wǎng)站都在在404頁面中做一個處理,
就是當(dāng)用戶3秒種內(nèi)還沒有任何操作的話,就會自動跳轉(zhuǎn)到其它頁面
技術(shù)實現(xiàn)有兩種方法
1. 在404頁面中的header間加上
<meta http-equiv=”refresh” content=”3;url=http://你跳轉(zhuǎn)的網(wǎng)站”>2. 用戶JS實現(xiàn)location
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK"> <title>404 Not Found</title> </head> <body><h1>找不到指定的頁面</h1><span id="totalSecond">3</span>秒后自動返回 </body> <script language="javascript" type="text/javascript"> <!--var second = document.getElementById('totalSecond').textContent;if (navigator.appName.indexOf("Explorer") > -1) //判斷是IE瀏覽器還是Firefox瀏覽器,采用相應(yīng)措施取得秒數(shù){second = document.getElementById('totalSecond').innerText;} else{second = document.getElementById('totalSecond').textContent;}setInterval("redirect()", 1000); //每1秒鐘調(diào)用redirect()方法一次function redirect(){if (second < 0){location.href = 'http://要跳轉(zhuǎn)的網(wǎng)站';} else{if (navigator.appName.indexOf("Explorer") > -1){document.getElementById('totalSecond').innerText = second--;} else{document.getElementById('totalSecond').textContent = second--;}}} --> </script> </html>---恢復(fù)內(nèi)容結(jié)束---
當(dāng)我們訪問一個頁面不存在的時候,就會跳到404頁面
一般網(wǎng)站都在在404頁面中做一個處理,
就是當(dāng)用戶3秒種內(nèi)還沒有任何操作的話,就會自動跳轉(zhuǎn)到其它頁面
技術(shù)實現(xiàn)有兩種方法
1. 在404頁面中的header間加上
<meta http-equiv=”refresh” content=”3;url=http://你跳轉(zhuǎn)的網(wǎng)站”>2. 用戶JS實現(xiàn)location
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK"> <title>404 Not Found</title> </head> <body><h1>找不到指定的頁面</h1><span id="totalSecond">3</span>秒后自動返回 </body> <script language="javascript" type="text/javascript"> <!--var second = document.getElementById('totalSecond').textContent;if (navigator.appName.indexOf("Explorer") > -1) //判斷是IE瀏覽器還是Firefox瀏覽器,采用相應(yīng)措施取得秒數(shù){second = document.getElementById('totalSecond').innerText;} else{second = document.getElementById('totalSecond').textContent;}setInterval("redirect()", 1000); //每1秒鐘調(diào)用redirect()方法一次function redirect(){if (second < 0){location.href = 'http://要跳轉(zhuǎn)的網(wǎng)站';} else{if (navigator.appName.indexOf("Explorer") > -1){document.getElementById('totalSecond').innerText = second--;} else{document.getElementById('totalSecond').textContent = second--;}}} --> </script> </html>轉(zhuǎn)載于:https://www.cnblogs.com/small-gray/p/5011948.html
總結(jié)
以上是生活随笔為你收集整理的404页面 3秒后跳到首页 实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: screenkey:linux中在屏幕上
- 下一篇: git安装和初步使用