프로그래밍/JavaScript

자바스크립트 모바일 브라우저 감지하기

SpiritLink 2018. 7. 17. 10:32

Javascript 에서 모바일 브라우저인지 감지하는 코드


static isMobile(){
// if we want a more complete list use this: http://detectmobilebrowsers.com/
// str.test() is more efficent than str.match()
// remember str.test is case sensitive
let isMobile = (/iphone|ipod|android|ie|blackberry|fennec/).test
(navigator.userAgent.toLowerCase());
return isMobile;
}