检测移动浏览器
问题: 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 ,