Created
September 12, 2021 21:36
-
-
Save wewindy/8b0de30c0a7a5bbedd5b50995a93f392 to your computer and use it in GitHub Desktop.
Regexp isMobile
This file contains hidden or 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
| const isMobile = /android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent); | |
| if (isMobile) { | |
| location.replace('手机页面'); | |
| } else { | |
| location.replace('PC页面'); | |
| } | |
| /* | |
| 作者:菜鸟码农Java笔记 | |
| 链接:https://www.zhihu.com/question/485560131/answer/2116400654 | |
| 来源:知乎 | |
| 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment