html5移动端需要用的js代码
来源:互联网 发布:以撒的结合yum heart 编辑:程序博客网 时间:2024/05/21 12:49
<!doctype html><html><head><meta charset="utf-8"><title>判断是否为移动端运行环境</title><meta name="keywords" content=""><meta name="description" content=""></head><body><script>// 判断是否为移动端运行环境var mob = '';if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){ if(window.location.href.indexOf("?mobile")<0){ try{ mob = 'true'; } catch(e){} } }else{ mob = 'false';};/*使用*/if(mob=='true') {$('.courseOpt_list').height(48);$('.ctrlBtn').css('bottom','-28px').find('i').removeClass('fa-angle-up').addClass('fa-angle-down').end().find('span').text('更多');} else {$('.courseOpt_list').height(68);$('.ctrlBtn').css('bottom','-28px').find('i').removeClass('fa-angle-up').addClass('fa-angle-down').end().find('span').text('更多');};/*获取链接参数*/function getQueryString(name) {var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");var r = window.location.search.substr(1).match(reg);if (r != null) return unescape(r[2]);return null;};//获取页面视口宽高function getViewRect() {var pageWidth = window.innerWidth,pageHeight = window.innerHeight;if ( typeof pageWidth != 'number' ) {if ( document.compatMode == 'CSS1Compat') {pageWidth = document.documentElement.clientWidth;pageHeight = document.documentElement.clientHeight;} else {pageWidth = document.body.clientWidth;pageHeight = document.body.clientHeight;}}return {width: pageWidth,height: pageHeight}; };/*判断横竖屏*/function hengshuping(){ if(window.orientation==180||window.orientation==0){ var h = getViewRect().height;$('html').css('minHeight',h + 'px'); } if(window.orientation==90||window.orientation==-90){ var h = getViewRect().height;$('html').css('minHeight',h + 'px'); } };if(mob == 'true') {$(window).on('orientationchange',function() {setTimeout(function() {hengshuping();},600); }); };var browser = {versions: function() {var u = navigator.userAgent, app = navigator.appVersion;return {//移动终端浏览器版本信息 trident: u.indexOf('Trident') > -1, //IE内核presto: u.indexOf('Presto') > -1, //opera内核webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器iPad: u.indexOf('iPad') > -1, //是否iPadwebApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部};}(),language: (navigator.browserLanguage || navigator.language).toLowerCase()}var ua = window.navigator.userAgent.toLowerCase();if(ua.match(/MicroMessenger/i) == 'micromessenger'){$('.wholePage').show();}else if(browser.versions.ios || browser.versions.iPhone || browser.versions.iPad){//$('#downMsg').show();location.href = 'https://itunes.apple.com/cn/app/id1149168395';}else{//$('#downMsg').show();location.href = "http://www1.zhiya100.com:8000/subject/app/zhiya100.apk";}</script> </body></html>
0 0
- html5移动端需要用的js代码
- 移动端js+html5
- 移动端html5开发关于用js检测用户设备
- 【移动前端】需要了解的HTML5 head 头标签
- 判断是否移动端设备的JS代码
- Three.js用鼠标控制场景移动的代码
- 手机端页面需要用rem设置字体大小的js代码
- 【Highcharts.js 】完美支持移动端、图表类型丰富、方便快捷的 HTML5 交互性图表库
- 移动端—HTML5手机网页需要加的那些meta/link标签,H5 meta全解
- backbone.js+jqm+html5的移动App开发总结一
- 注册页面需要的js代码
- html5移动端:元素拖动/触控touch(js)(jquery)
- html5移动端:手机旋转(js)(jquery)
- html5移动端:手机触控gesturestart(js)
- jQuery 移动端HTML5 弹出窗插件 box.js
- html5移动端:元素拖动/触控touch(js)(jquery)
- <html5+css3+js>事件触发js代码的不同方式
- 利用HTML5实现移动端的涂鸦
- 使用Genymotion 模拟器来打开百度地图项目报错:
- tjut 5949
- Spring AOP自定义切面
- Android Studio Gradle Could not reserve enough space for object heap
- Spring对异常的统一处理
- html5移动端需要用的js代码
- 第十周 项目3-利用遍历思想解决问题
- 分布式Unique ID的生成原理
- QDEZ AC题目
- 在MyEclipse和Eclipse中无法废弃svn地址
- 使用burpsuite抓火狐浏览器HTTPS包
- 无线基础知识普及第一讲
- Intel处理器被曝惊人后门:…
- 无线基础知识普及第二讲