js判斷是pc或移動端核心程式碼
阿新 • • 發佈:2022-05-28
<script type="text/javascript"> var os = function () { var ua = navigator.userAgent, isWindowsPhone = /(?:Windows Phone)/.test(ua), isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone, isAndroid = /(?:Android)/.test(ua), isFireFox = /(?:Firefox)/.test(ua), isChrome = /(?:Chrome|CriOS)/.test(ua), isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)), isPhone = /(?:iPhone)/.test(ua) && !isTablet, isPc = !isPhone && !isAndroid && !isSymbian; return { isTablet: isTablet, isPhone: isPhone, isAndroid: isAndroid, isPc: isPc }; }(); if(os.isPc){ location.replace("http://www.onlymid.com.cn/"); } if (os.isAndroid || os.isPhone) { location.replace('http://www.onlymid.com.cn/html/2016shujia/wap/'); } else if (os.isTablet) { location.replace('http://www.onlymid.com.cn/html/2016shujia/wap/'); } </script>