是否可以从移动设备中排除/忽略该 javascript?
function doSomething() {
location.reload();
};
var resizeTimer = null;
$(window).bind('resize', function() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});
谢谢!
是否可以从移动设备中排除/忽略该 javascript?
function doSomething() {
location.reload();
};
var resizeTimer = null;
$(window).bind('resize', function() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});
谢谢!
jQuery 只是包装了标准的 resize DOM 事件,例如。
window.onresize = function(event) {
...
}
$(function(){
var mobile;
if (window.width < 481) {
mobile = 1;
}
if (!mobile) {
// All your stuff.
}
});
//Class for Detecting Mobile devices
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
var resizeTimer = null;
//if not mobile do resize
if( !isMobile.any() ){
$(window).bind('resize', function() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});
};
function doSomething() {
location.reload();
};
供你参考
http://www.abeautifulsite.net/blog/2011/11/detecting-mobile-devices-with-javascript/