从移动设备中排除javascript窗口大小调整
是否可以从移动设备中排除/忽略该javascript从移动设备中排除javascript窗口大小调整,javascript,jquery,mobile,Javascript,Jquery,Mobile,是否可以从移动设备中排除/忽略该javascript function doSomething() { location.reload(); }; var resizeTimer = null; $(window).bind('resize', function() { if (resizeTimer) clearTimeout(resizeTimer); resizeTimer = setTimeout(doSomething, 100); }); 谢谢 jQuery只是包装了标准的调整D
function doSomething() {
location.reload();
};
var resizeTimer = null;
$(window).bind('resize', function() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});
谢谢 jQuery只是包装了标准的调整DOM大小事件,例如
window.onresize = function(event) {
...
}
$(function(){
var mobile;
if (window.width < 481) {
mobile = 1;
}
if (!mobile) {
// All your stuff.
}
});
window.onresize=函数(事件){
...
}
$(函数(){
移动增值税;
如果(窗宽<481){
mobile=1;
}
如果(!移动){
//你所有的东西。
}
});
//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();
};
供参考
你能给我举个代码示例吗?我是一个javascript初学者。非常感谢!谢谢看起来也很棒。谢谢!看起来不错。我尝试过,但现在在调整大小后,窗口将不会在普通浏览器上重新加载。因为缺少doSomething()。。我修好了!再试一次你是我的国王:)很好!非常感谢。