pc,모바일 구분 - 안드로이드, iOS 구분하기
2021. 2. 17.
웹 / 모바일 브라우저 구분
var mobile_filter_ = "win16|win32|win64|mac|macintel";
if ( navigator.platform ) {
if ( mobile_filter_.indexOf( navigator.platform.toLowerCase() ) < 0 ) {
//mobile 브라우저
// do something
} else {
//pc 브라우저
// do something
}
}
.
.
iOS / Android 구분
var currentOS;
$(document).ready(function(){
var mobile = (/iphone|ipad|ipod|android/i.test(navigator.userAgent.toLowerCase()));
if (mobile) { //navigator.userAgent에 /iphone|ipad|ipod|android 의 단어포함이 true 일때
// 유저에이전트를 불러와서 OS를 구분합니다.
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.search("android") > -1){
currentOS = "android";
}else if ((userAgent.search("iphone") > -1)
|| (userAgent.search("ipod") > -1)
|| (userAgent.search("ipad") > -1)){
currentOS = "ios";
} else {
// 모바일이 아닐 때
currentOS = "nomobile";
}
});
.
'JS_CSS' 카테고리의 다른 글
[window.postMessage] 크로스 도메인 iframe 높이 조절하기 (0) | 2021.02.17 |
---|---|
[css for IE] IE8,9 CSS핵 (0) | 2021.02.17 |
[JQuery] map 으로 join하는 함수 - 일렬화 (0) | 2021.02.17 |
[jBox] Options (0) | 2021.02.01 |
(box_img) 가로세로 길이 상관없이 부모박스에 이미지 사이즈 조절 (0) | 2021.01.31 |