日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

404页面 3秒后跳到首页 实现

發(fā)布時間:2023/12/13 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。