Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- IntersectionObserver
- dom
- 애니메이션
- This
- 클로저
- Push
- ios
- map
- 스크롤
- video
- json
- Flex
- ES6
- 배열
- event
- scroll
- 이벤트 루프
- input
- ajax
- slice
- 모듈
- Promise
- 객체
- animation
- array
- 문자열
- object
- 이벤트
- 비동기
- 이벤트 위임
Archives
- Today
- Total
FEDev Story
Mobile 접속인지 확인하는 방법 본문
javascript로 PC접속, mobile접속인지 확인하는 방법을 찾아보았다.
navigator로 판별
var filter = "win16|win32|win64|mac";
if( navigator.platform ){
if( filter.indexOf(navigator.platform.toLowerCase())<0 ){
alert("모바일접속");
}else{
alert("PC접속");
}
}
터치이벤트 생성 가능여부로 판별
if (('createTouch' in document) || ('ontouchstart' in document)){
alert("모바일접속");
} else {
alert("PC접속");
}
HTML5/CSS3 Modernizr를 이용하면 된다고함..
if (Modernizr.touch){
// bind to touchstart, touchmove, etc and watch `event.streamId`
} else {
// bind to normal click, mousemove, etc
}
'Mobile' 카테고리의 다른 글
| [JS] IOS의 CLICK 버블링이 발생하지 않아요 (0) | 2019.11.11 |
|---|---|
| [Plugin] 터치 이벤트와 더블탭 이벤트 (0) | 2016.05.02 |
Comments