gpt4 book ai didi

javascript - 排除移动设备中的 javascript 窗口调整大小

转载 作者:行者123 更新时间:2023-12-02 18:24:35 25 4
gpt4 key购买 nike

是否可以从移动设备中排除/忽略该 JavaScript?

function doSomething() {
location.reload();
};

var resizeTimer = null;
$(window).bind('resize', function() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});

谢谢!

最佳答案

//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/

关于javascript - 排除移动设备中的 javascript 窗口调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18508179/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com