以下代码是插入到手机模板中
<script type="text/javascript"> var system = { win: false, mac: false, xll: false }; var p = navigator.platform; system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); if (system.win || system.mac || system.xll) { window.location.href = "填写你电脑的根跟网址"; } else {} </script>
以下是电脑跳转,插入到电脑模板的js文件中
var browser = { versions: function () { var u = navigator.userAgent, app = navigator.appVersion; return { trident: u.indexOf('Trident') > -1, presto: u.indexOf('Presto') > -1, webKit: u.indexOf('AppleWebKit') > -1, gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), ios: !!u.match(/i[^;]+;( U;)? CPU.+Mac OS X/), android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, iPhone: u.indexOf('iPhone') > -1 || (u.indexOf('Mac') > -1 && u.indexOf ('Macintosh') < 0), iPad: u.indexOf('iPad') > -1, webApp: u.indexOf('Safari') == -1 };} (),language: (navigator.browserLanguage || navigator.language).toLowerCase()} if(!browser.versions.iPad){ if (browser.versions.android || browser.versions.iPhone) { self.location = "填写你的手机站根网址"; }}