當前位置:首頁 » 密碼管理 » js判斷是否手機訪問

js判斷是否手機訪問

發布時間: 2025-07-24 23:03:17

㈠ 如何用js判斷是用電腦訪問還是用手機訪問網站

這里有兩種比較簡單的方法可以使用:
解決方案一
<script type="text/javascript">
//判斷是否移動端訪問
browserRedirect();
function browserRedirect() {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";

if (!(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) {
//window.location.href = "http://gz.gzwhir.com/jpcg201409177619/index.aspx";
}
}
</script>

解決方案二
<script src="http://siteapp..com/static/webappservice/uaredirect.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("你的手機版網址");</script>

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:647
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:939
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:634
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:823
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:734
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1069
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:302
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:163
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:855
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:765