자바스크립트 모바일기기 확인(javascript mobile detect)
자바스크립트로 모바일인지 아닌지 확인하기 위해서는 일단 UserAgent를 확인해봐야한다.
아래 주소에서 UserAgent 내용을 확인 할 수 있다.
모바일기기 체크
<script type="text/javascript">
function isMobile(){
var UserAgent = navigator.userAgent;
if (UserAgent.match(/iPhone|iPod|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null || UserAgent.match(/LG|SAMSUNG|Samsung/) != null)
{
return true;
}else{
return false;
}
}
if(isMobile()){
location.href = "/mobile/index.html"; //모바일페이지
}else{
location.href = "/main.html"; //PC용 페이지
}
</script>
'Study > Jquery' 카테고리의 다른 글
bxslider slider (0) | 2016.12.19 |
---|---|
jquery , javascript(자바스크립트) 날짜 더하고 빼기 (dateAdd) (0) | 2016.01.12 |
쓸만한 40여개 jquery plugin (0) | 2014.01.24 |
jquery plugin 예제모임 사이트들 (2) | 2014.01.24 |
전화번호 정규식, 이메일 정규식, 빈값체크 정규식 (0) | 2014.01.22 |