//if(navigator.platform.indexOf('iPad') != -1){ // 获取IE版本 function IEVersion() { // 取得浏览器的userAgent字符串 var userAgent = navigator.userAgent; // 判断是否为小于IE11的浏览器 var isLessIE11 = userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1; // 判断是否为IE的Edge浏览器 var isEdge = userAgent.indexOf('Edge') > -1 && !isLessIE11; // 判断是否为IE11浏览器 var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf('rv:11.0') > -1; if (isLessIE11) { var IEReg = new RegExp('MSIE (\\d+\\.\\d+);'); // 正则表达式匹配浏览器的userAgent字符串中MSIE后的数字部分,,这一步不可省略!!! IEReg.test(userAgent); // 取正则表达式中第一个小括号里匹配到的值 var IEVersionNum = parseFloat(RegExp['$1']); if (IEVersionNum === 7) { // IE7 return 7 } else if (IEVersionNum === 8) { // IE8 return 8 } else if (IEVersionNum === 9) { // IE9 return 9 } else if (IEVersionNum === 10) { // IE10 return 10 } else { // IE版本<7 return 6 } } else if (isEdge) { // edge return 'edge' } else if (isIE11) { // IE11 return 11 } else { // 不是ie浏览器 return -1 } } if(IEVersion()!=7&&IEVersion()!=8&&IEVersion()!=6){ console.log('ok'); (function () { function resize() { var html = document.getElementsByTagName('html')[0]; var width = html.clientWidth; var height = html.clientHeight; var max = width > height ? width : height; var min = width > height ? height : width; $('body').css({'width':max + "px",'height':min + "px"}); console.log(max,min); } resize(); window.addEventListener("resize", resize) })(); window.addEventListener("orientationchange", function(event) { // 根据event.orientation|screen.orientation.angle等于0|180、90|-90度来判断横竖屏 if(screen.orientation.angle==90){ console.log('竖屏') } }, false); function mobile_device_detect(url) { var thisOS=navigator.platform; var os=new Array("iPhone","android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","UNTRUSTED/1.0","Windows CE","BlackBerry","IEMobile"); for(var i=0;i<os.length;i++) { if(thisOS.match(os[i])) { window.location=url; } } var check = navigator.appVersion; if( check.match(/linux/i) ) { //X11是UC浏览器的平台 ,如果有其他特殊浏览器也可以附加上条件 if(check.match(/mobile/i) || check.match(/X11/i)) { window.location=url; } } Array.prototype.in_array = function(e) { for(i=0;i<this.length;i++) { if(this[i] == e) return true; } return false; } } mobile_device_detect("https://m.yinqingli.com/"+window.location.pathname); }else{ console.log('ie6,7,8'); }