判断如果是手机端访问那么跳转到指定页面,一般的话适用于企业站,或者有其他需求的网站。

以下的代码已做过压缩

<script type="text/javascript">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="此处填写网址";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

这段代码实测效果不错,html转换为js需要的话 点击这里跳转

最后修改:2020 年 03 月 14 日
如果觉得我的文章对你有用,请随意赞赏