이 블로그 검색

2011년 3월 23일 수요일

스마트폰으로 접근시 모바일홈페이지로 자동이동

<% 
String browser = request.getHeader("User-Agent");
boolean result = false;
if (browser.indexOf("Android") >0) {  // 안드로이드
 result = true;
 } else if (browser.indexOf("iphone","iPod","PPC") > 0) {  // 아이폰등등..
 result = true;
 }
 if (result == true) {
 response.sendRedirect("이동할경로");
 }
%>









<script type="text/javascript">
var mobileKeyWords = new Array('iPhone', 'iPod', 'BlackBerry', 'Android', 'Windows CE', 'LG', 'MOT', 'SAMSUNG', 'SonyEricsson'); 
for (var word in mobileKeyWords){ 
    if (navigator.userAgent.match(mobileKeyWords[word]) != null){ 
        location.href = "http://m.i-sh.co.kr/"; 
        break; 
    } 



</script>

댓글 없음:

댓글 쓰기