반응형

결론 부터 말씀 드리면 "Mobi" 가 User agent에 포함되어 있으면 모바일 입니다.

 

 
 

 

------------------------------------------------------------------------------------

모바일, 태블릿 혹은 데스크탑섹션

The most common reason to perform user agent sniffing is to determine which type of device the browser runs on. The goal is to serve different HTML to different device types.

  • Never assume that a browser or a rendering engine only runs on one type of device. Especially don't make different defaults for different browsers or rendering engines.
  • Never use the OS token to define if a browser is on mobile, tablet or desktop. The OS may run on more than one type of (for example, Android runs on tablets as well as phones).

The following table summarizes the way major browser vendors indicate that their browsers are running on a mobile device:

Common browsers User Agent strings
브라우저 규칙 예제
Mozilla (Gecko, Firefox) Mobile or Tablet token in the comment. Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0
WebKit-based (Android, Safari) Mobile Safari tokenoutside the comment. Mozilla/5.0 (Linux; U; Android 4.0.3; de-ch; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Blink-based (Chromium, Google Chrome, Opera 15+) Mobile Safari tokenoutside the comment Mozilla/5.0 (Linux; Android 4.4.2); Nexus 5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Mobile Safari/537.36 OPR/20.0.1396.72047
Presto-based (Opera 12-)

Opera Mobi/xyz tokenin the comment (Opera 12-)

Opera/9.80 (Android 2.3.3; Linux; Opera Mobi/ADR-1111101157; U; es-ES) Presto/2.9.201 Version/11.50

Internet Explorer IEMobile/xyz token in the comment. Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)

In summary, we recommend looking for the string “Mobi” anywhere in the User Agent to detect a mobile device.

If the device is large enough that it's not marked with “Mobi”, you should serve your desktop site (which, as a best practice, should support touch input anyway, as more desktop machines are appearing with touchscreens).

 

 

참고 URL : https://developer.mozilla.org/ko/docs/Web/HTTP/User_agent%EB%A5%BC_%EC%9D%B4%EC%9A%A9%ED%95%9C_%EB%B8%8C%EB%9D%BC%EC%9A%B0%EC%A0%80_%EA%B0%90%EC%A7%80#%EB%AA%A8%EB%B0%94%EC%9D%BC_%ED%83%9C%EB%B8%94%EB%A6%BF_%ED%98%B9%EC%9D%80_%EB%8D%B0%EC%8A%A4%ED%81%AC%ED%83%91

반응형

'스크립트' 카테고리의 다른 글

javascript object length 구하기.  (0) 2019.06.30
css - 줄바꿈  (0) 2019.05.15
vim - 하이라이트 끄기  (0) 2019.05.13
IE img label for 클릭 안될때 처리  (4) 2019.03.27
html5 javascript 이미지 미리보기  (0) 2018.11.29
cmd process kill  (0) 2018.11.17
javascript padStart - left padding  (0) 2018.11.07
curl 기본 사용법  (0) 2018.11.07

+ Recent posts