컴퓨터/HTML & JS & TS

HTML 모바일 감지 JavaScript

두뇌미포함 2016. 9. 3. 15:55
728x90
반응형

 

1. 화면 회전 값 여부

function isMobileDevice() {
    return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);
};

 

2. 그냥 useragent로 체크

if (/Android|iPhone|iPod|iPad|BlackBerry|BB|webOS|PlayBook|Windows Phone|IEMobile|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) {
   // Do Mobile
} else {
   // Do
}

 

728x90