不忘初心 牢记使命
网络强国 科技创新
分享一段js判断手机访问并跳转到手机版网页代码
<script type="text/javascript"> function redirectMobile() { var nowUrl = location.href, nowHost = location.host, nowPathname = location.pathname, jumpUrl = '', mobileUrl = 'http://m.5ixuexiwang.com'; mobileHurl = GetUrlRelativePath(); 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) { try { if (nowUrl == 'http://www.5ixuexiwang.com/') { jumpUrl = mobileUrl; } else if (nowHost != 'm.5ixuexiwang.com') { jumpUrl = mobileUrl + mobileHurl; } if (jumpUrl) location.href = jumpUrl; } catch(e) {} } } function GetUrlRelativePath() { var url = document.location.toString(); var arrUrl = url.split("//"); var start = arrUrl[1].indexOf("/"); var relUrl = arrUrl[1].substring(start); return relUrl; } redirectMobile(); </script>
2025互联网科技大会暨中国人工智能应用发展大会/中国AI节在北京隆重举行启动仪式
2025深圳市互联网学会春茗座谈会在厉害猫举行,2025年工作规划。将坚持“一周一走...
咨询热线
地址:深圳市龙岗区坂田街道坂田国际中心E栋二层209房