2011-07-29 5 views

답변

0

당신은 서버에 브라우저 요청 헤더 (사용자 에이전트)를 테스트하고 그에 따라 프레임 워크를 결합해야합니다 :

예를 (; U; 윈도우 NT 6.1, 드, 윈도우 RV : 1.9.2.18) 모질라/5.0 : http://pgl.yoyo.org/http/browser-headers.php 사용자 에이전트 참조 게코를/20110614 파이어 폭스 다음/3.6.18

1

클라이언트에서 그 일을하는 한 가지 방법은 :

<html> 
    <head> 
     <script type="text/javascript"> 
       function isMobileDevice() { 
       var index = navigator.appVersion.indexOf("Mobile"); 
    return (index > -1); 
       } 
       function loadJQuery() { 
       if(isMobileDevice()) 
        document.write("<script type='text/javacript src='"+path_to_mobile_jquery+"'></script>"); 
       else 
document.write("<script type='text/javacript src='"+path_to_normal_jquery+"'></script>"); 
       } 
     </script> 
    </head> 
    <body onload="loadJQuery();"> 
     <!-- Content --> 
    </body> 
</html> 
1

아마도 window.navigator.userAgent에 대해 가능한 브라우저 유형의 열거 한 후 테스트를 구축? Modernizr과 같은 라이브러리를 사용하여 기능을 테스트 할 수 있지만 실제 브라우저 유형은 얻을 수 없습니다. 브라우저 클래스 (데스크톱, 태블릿, 모바일 등)를 식별 할 수있는 (아직) userAgent 소품이 없으므로 바보 같은 UA 비교를 할 수 없습니다.

51 Degrees과 같은 프로젝트는이 평가를 단순화하기위한 것이지만 숨겨진 비용이 발생합니다. 즉, 51 도는 클라이언트 브라우저를 평가하고 그에 따라 리디렉션하는 데 10 초 이상 걸립니다. 물론, 귀하의 경우, 당신은 조건부 스타일을 원한다. 이는 window.navigator.userAgent 수표가 if(true) document.write('<javascript resource />') 유형 접근 방식에 도움이 될 수 있음을 나타냅니다.

관련 문제