검색결과 리스트
글
모바일 과 웹페이지를 분기 해주는 스크립트이다..
<script type="text/javascript">
if (navigator.userAgent.match(/iPad/) == null && navigator.userAgent.match(/Mobile|Windows CE|Windows Phone|Opera Mini|POLARIS/) != null)
location.href = "http://" + location.host + "/m" + location.pathname;
</script>
간단하다.. 안드로이드 폰과 아이폰 모두 잡아낸다^^
<script language="JavaScript">
//모바일 페이지로 이동.
var uAgent = navigator.userAgent.toLowerCase();
var mobilePhones = new Array('iphone','ipod','android','blackberry','windows ce',
'nokia','webos','opera mini','sonyericsson','opera mobi','iemobile');
for(var i=0;i<mobilePhones.length;i++)
if(uAgent.indexOf(mobilePhones[i]) != -1)
document.location = "http://"+ location.host +"/m" + location.pathname;
</script>
더욱더 자세하게 잡아낼수 있지만.. 굳이 위의 소스를 사용하는 것을 추천한다!!
복잡하다고 좋은게 아니라 얼마나 간단히 쉽게 처리 하는것이 고수로 가는 지름길이라 생각이 든다 ^^
그럼 이만... 즐프~
'SCRIPT > javascript' 카테고리의 다른 글
| 채팅창 스크롤 포커싱script (0) | 2010/10/27 |
|---|---|
| 웹페이지 모바일 페이지 분기(script) (0) | 2010/10/12 |
| 자바스크립트 기반 달력 (0) | 2010/05/29 |
| 자바스크립트 초단위 호출(재귀적) (0) | 2010/05/26 |
RECENT COMMENT