请知悉:本文最近一次更新为 7年 前,文中内容可能已经过时。

以下示例代码实现判定移动端并自动跳转的功能:

<script type="text/javascript">
wapurl="https://test.com/";if(window.location.toString().indexOf('pref=padindex')!=-1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent)||(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf(" mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href=wapurl}else if(/iPad/i.test(navigator.userAgent)){window.location.href=wapurl}else{window.location.href=wapurl}}catch(e){}}}}
</script>

如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《一句话JS判定移动端自动跳转》相关的博文:


留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌