노드js·자바스크립트

userAgent로 접속한 기기가 모바일인지 확인 하는 방법

김일국 2014. 12. 15. 13:36

모바일 기기로 접속하면 반응형 웹으로 이동하게 처리(아래 소스)

<script type="text/javascript">
if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))||(navigator.userAgent.match(/android/i)))
{
location.replace('http://time-space.biz/rs_web/');
}else{
location.replace('http://time-space.biz/');
}
</script>