Last active
October 30, 2019 09:17
-
-
Save seunggabi/2a3c46e665a3b80d1cb1e131d005121c to your computer and use it in GitHub Desktop.
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 = (userAgent) => { | |
userAgent = userAgent || window.navigator.userAgent; | |
const device = ['iPhone', 'iPod', 'Android', 'Windows CE', 'BlackBerry', 'Symbian', 'Windows Phone', 'webOS', 'Opera Mini', 'Opera Mobi', 'POLARIS', 'IEMobile', 'lgtelecom', 'nokia', 'SonyEricsson', 'LG', 'SAMSUNG'].join('|'); | |
const regexp = new RegExp(device, 'i'); | |
return regexp.test(userAgent); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[reference] https://cheolgoon.tistory.com/entry/%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%EB%AA%A8%EB%B0%94%EC%9D%BC%EA%B8%B0%EA%B8%B0-%ED%99%95%EC%9D%B8javascript-mobile-detect