在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?
推荐答案
我认为这个答案更好,因为它不取决于屏幕宽度:
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屋!
查看全文