728x90
var Device = {ENV_DESKTOP: 'desktop',ENV_PHONE: 'phone',ENV_TABLET: 'tablet',ENV_PORTRAIT: 'portrait',ENV_LANDSCAPE: 'landscape',agent: {mobile: (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(window.navigator.userAgent.toLowerCase())),tablet: (/ipad|android|android\s3\.0|xoom|sch-i800|playbook|tablet|kindle/i.test(window.navigator.userAgent.toLowerCase()))},resolutions: {phones: {width: [240, 960],height: [320, 800]},tablets: {width: [1024, 2048],height: [60, 1536]}},support: {orientation: ('DeviceOrientationEvent' in window),motion: ('DeviceMotionEvent' in window),touch: ('ontouchstart' in window)},standalone: ('standalone' in window.navigator),detect: function () {var that = this,inRange = function (type) {var size = that.screenSize(),collection = that.resolutions[type];return ((size.width >= collection.width[0] && size.width <= collection.width[1]) && (size.height >= collection.height[0] && size.height <= collection.height[1]));};if (this.agent.mobile && inRange('phones')) {this.type = this.ENV_PHONE;} else {this.type = (this.agent.tablet && inRange('tablets')) ? this.ENV_TABLET : this.ENV_DESKTOP;}},orientation: function () {return this.support.orientation ? (window.orientation !== 0 ? this.ENV_PORTRAIT : this.ENV_LANDSCAPE) : null;},screenSize: function () {var portrait = (this.orientation() === this.ENV_PORTRAIT);return {width: portrait ? screen.height : screen.width,height: portrait ? screen.width : screen.height};},hideKeyboard: function () {document.activeElement.blur();},hideUrlBar: function () {if (this.type === this.ENV_PHONE) {setTimeout(function () {window.scrollTo(0, 1);}, 0);}}};
호출방법은 나중에 테스트 해보고 다시...
출처 : http://ultteky.egloos.com/10983523
'내가 자꾸 까먹어서 쓰는 개발 이야기 > JavaScript' 카테고리의 다른 글
[펌] http multi file download via javascript (0) | 2014.02.04 |
---|---|
업로드 전 파일 용량 체크하기 (0) | 2013.02.28 |
[펌] 크롬에서 ModalWindow의 리턴값 받기 (0) | 2013.01.16 |
스크립트에서 number_format (0) | 2009.10.20 |
브라우저 안쪽의 사이즈 (0) | 2008.06.10 |
최근댓글