Browser detection in JavaScript? [duplicate]

2018-12-31 03:28发布

This question already has an answer here:

How do I determine the exact browser and version using JavaScript?

26条回答
墨雨无痕
2楼-- · 2018-12-31 04:17

All the information about web browser is contained in navigator object. The name and version are there.

var appname = window.navigator.appName;

Source: javascript browser detection

查看更多
春风洒进眼中
3楼-- · 2018-12-31 04:19

You could use the jQuery library to detect the browser version.

Example:

jQuery.browser.version

However, this only makes sense if you are also using other functions of jQuery. Adding an entire library just to detect the browser seems like overkill to me.

More information: http://api.jquery.com/jQuery.browser/

(you have to scroll down a bit)

查看更多
登录 后发表回答