Last active
March 11, 2018 13:18
-
-
Save cssmagic/6238619 to your computer and use it in GitHub Desktop.
让手机用户自动跳转到移动版网站。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ua = _ua || {}; | |
_ua.str = navigator.userAgent.toLowerCase(); | |
_ua.isAndroid = _ua.str.indexOf('android') > -1 && _ua.str.indexOf('mobile') > -1; | |
_ua.isIPhone = /\(i(?:phone|pod);/.test(_ua.str); | |
if (_ua.isAndroid || _ua.isIPhone) { | |
location.href = 'http://m.example.com/'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在服务端跳转对蜘蛛更友好,效率也更高