如何通过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/