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
- 클로저
- 이벤트 위임
- object
- video
- 모듈
- scroll
- 배열
- Flex
- dom
- input
- 비동기
- 스크롤
- json
- event
- Push
- 이벤트 루프
- 객체
- 이벤트
- map
- array
- Promise
- animation
- 문자열
- This
- 애니메이션
- slice
- IntersectionObserver
- ios
- ES6
- ajax
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