检测移动浏览器

元气小坏坏 提交于 2020-08-05 23:16:50

问题:

I'm looking for a function which return boolean value if user has mobile browser or not. 我正在寻找一个函数,如果用户具有或没有移动浏览器,则该函数返回布尔值。

I know that I can use navigator.userAgent and write that function by using regex, but user-agents are too various for different platforms. 我知道我可以使用navigator.userAgent并通过使用正则表达式来编写该功能,但是对于不同的平台,用户代理太多了。 I doubt that match all possible devices would be easy, and I think this problem has been solved before many times so there should be some kind of complete solution for such task. 我怀疑匹配所有可能的设备是否容易,而且我认为这个问题已经解决了很多次,因此应该为这种任务提供某种完整的解决方案。

I was looking at this site , but sadly the script is so cryptic that I have no idea how to use it for my purpose, which is to create a function which return true / false. 我当时在看这个站点 ,但是可悲的是脚本太神秘了,以至于我不知道如何使用它来创建一个返回true / false的函数。


解决方案:

参考一: https://stackoom.com/question/lktN/检测移动浏览器
参考二: https://oldbug.net/q/lktN/Detecting-a-mobile-browser
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!