判断是pc端还是手机端,并跳转到相应页面


<!-- 判断浏览器是否为手机端 --> <script> // class ! function(navigator) { var userAgent = navigator.userAgent; documentElement = document.documentElement; if (userAgent.match(/micromessenger\/5/gi)) { documentElement.className += " mobile wx_mobile wx_mobile_5"; } else if (userAgent.match(/micromessenger/gi)) { documentElement.className += " mobile wx_mobile"; } else if (userAgent.match(/ucbrowser/gi)) { documentElement.className += " mobile uc_mobile"; } else if (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent.toLowerCase())) { documentElement.className += " mobile"; } else if (userAgent.toLowerCase().match(/msie/gi) && (parseFloat(userAgent.toLowerCase().match(/msie ([0-9]{1,}[\.0-9]{0,})/i)[1] || 999) < 9)) { documentElement.className += " pc pc-ie pc-ie8"; } else if (userAgent.toLowerCase().match(/msie/gi) || navigator.msPointerEnabled || navigator.pointerEnabled) { documentElement.className += " pc pc-ie"; } else { documentElement.className += " pc"; ispc = true; } /* 如果是Pc端,则打开下面这页面 */ if(isPc){ window.location.href='url'; } /* 如果不是pc端,则打开下面这页面*/ /* if(!isPc){ window.location.href='url'; } */ }(navigator); // meta ! function(userAgent) { var screen_w = parseInt(window.screen.width), scale = screen_w / 640; if (/Android (\d+\.\d+)/.test(userAgent)) { var version = parseFloat(RegExp.$1); document.write(version > 2.3 ? '<meta name="viewport" content="width=640, minimum-scale = ' + scale + ", maximum-scale = " + scale + ', target-densitydpi=device-dpi">' : '<meta name="viewport" content="width=640 target-densitydpi=device-dpi">'); } else { document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">'); } }(navigator.userAgent); </script> 优质内容筛选与推荐>>
1、看完哪吒之魔童降世,突然想起以前考研时的…
2、win32API获取Cookie
3、ubuntu下各文件夹
4、Android开发_SharedPreferences
5、[CF612D] The Union of k-Segments(排序,扫描线)


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号