在 javascript 中“如果手机" [英] In javascript 'If mobile phone'
本文介绍了在 javascript 中“如果手机"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在考虑使用 jQuery.browser 做一些事情,但这只会返回您所在的浏览器,以及它是否是 webkit 等.
I was thinking of doing something with the jQuery.browser but this only returns which browser you're in and if its a webkit etc etc.
所以,如果您使用的是移动设备,我基本上想关闭某些 js 文件的加载功能?
So i basically want to turn off certain js files from even loading if you're on a mobile device?
我认为你可以做到,但怎么做?
I assume you can do it but how?
推荐答案
我认为这个答案更好,因为它没有't 取决于屏幕宽度:
I think this answer is better because it doesn't depends on screen width:
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
// some code..
}
我知道现在您对品牌浏览器有依赖性,但这比检查屏幕尺寸更易于维护.
I know that now you've got a brand browser dependency, but this is a bit more maintainable that checking for the screen size.
这篇关于在 javascript 中“如果手机"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文