var dropdownLi = $('li#nav-goods'); dropdownLi.mouseover(function() { $(this).addClass('open'); }).mouseout(function() { $(this).removeClass('open'); }); } $(document).ready(function(){ dropdownOpen();//调用 $('#nav-goods').mouseover(function(){ $(this).next().show(); }); }); $(function(){ // var ua = navigator.userAgent.toLowerCase(); // var bIsIpad = ua.match(/ipad/i) == "ipad"; // var bIsIphoneOs = ua.match(/iphone os/i) == "iphone os"; // var bIsAndroid = ua.match(/android/i) == "android"; // var bIsWM=ua.match(/windows mobile/i)=="windows mobile"; // var host = "https://m.www.chenkeiot.com"; // console.log(ua,bIsIpad,bIsIphoneOs,bIsAndroid,bIsWM); // var pathname = window.location.pathname; // if(bIsIpad||bIsIphoneOs||bIsAndroid||bIsWM){ // window.location.href =host + pathname; // } console.log("start"); var MobileUA = (function() { var ua = navigator.userAgent.toLowerCase(); var mua = { IOS: /ipod|iphone|ipad/.test(ua), //iOS IPHONE: /iphone/.test(ua), //iPhone IPAD: /ipad/.test(ua), //iPad ANDROID: /android/.test(ua), //Android Device WINDOWS: /windows/.test(ua), //Windows Device TOUCH_DEVICE: ('ontouchstart' in window) || /touch/.test(ua), //Touch Device MOBILE: /mobile/.test(ua), //Mobile Device (iPad) ANDROID_TABLET: false, //Android Tablet WINDOWS_TABLET: false, //Windows Tablet TABLET: false, //Tablet (iPad, Android, Windows) SMART_PHONE: false //Smart Phone (iPhone, Android) }; mua.ANDROID_TABLET = mua.ANDROID && !mua.MOBILE; mua.WINDOWS_TABLET = mua.WINDOWS && /tablet/.test(ua); mua.TABLET = mua.IPAD || mua.ANDROID_TABLET || mua.WINDOWS_TABLET; mua.SMART_PHONE = mua.MOBILE && !mua.TABLET; return mua; }()); console.log(MobileUA.SMART_PHONE,'YES'); // 分辨率改变时候执行代码 $(window).resize(function() { // alert($(window).width()); // alert($(window).height()); var windowWidth = $(window).width(); // console.log(windowWidth); var url = document.location.toString(); // if(windowWidth < 980) // { // var link =url.replace('www.makuwang','m.makuwang'); // window.location.href =link; // console.log(link); // return false; // } }); if (MobileUA.SMART_PHONE) { // var url = document.location.toString(); // var link =url.replace('www.chenkeiot.com','www.chenkeiot.com/m'); // window.location.href =link; // console.log(link); // return false; } });