javascript - 通过 javascript 比较浏览器版本

标签 javascript browser

如何通过javascript比较浏览器版本?

例如,如果脚本想知道用户是否使用 Firefox 3.5+

有什么办法吗?

最佳答案

你应该雇用object/feature detection以确保某些东西在你应用它之前会起作用。从该链接:

While browser detection works well enough for 90% of your visitors, some obscure browsers won't be treated correctly and browsers that appear after you've written the page may not be adequately covered either. The results would be either a stream of error messages or a script that isn't called while the browser can easily handle it. In both cases, you're cheating your end users and coding incorrectly.

要获取浏览器版本,您可以使用 Navigator object :

alert(navigator.appName + ' ' + navigator.appVersion);

关于javascript - 通过 javascript 比较浏览器版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2802993/

相关文章:

javascript - 如何处理for循环中nodejs的回调函数?

javascript - 如何在 javascript 代码中使用模型数据?

javascript - 如何修复文本字段中错误的键盘布局引起的错误

xml - Web 浏览器是否处理 "xmlns"属性?

iphone - 获取iOS上已安装的Web浏览器应用程序的列表

javascript - 选中复选框时如何刷新页面的一部分?

javascript - 使用 jQuery 触发 oninput 事件

windows - 如何检测安装了哪个版本的 Internet Explorer?

javascript - 在运行时确定浏览器是否太慢而无法优雅地处理复杂的 JavaScript/CSS 的最佳方法是什么?

javascript - IE6 Javascript ClassName 改变显示