why Does “navigator.userAgent” in javaScript returns the String “Mozilla” when tried in a google chrome borwser?

前端 未结 2 1227
死守一世寂寞
死守一世寂寞 2021-02-05 19:38

Im developing a javaScript code and I want to determine the version and brand of the client\'s browser, here\'s the piece of code I\'m using to do so :

var bro         


        
2条回答
  •  盖世英雄少女心
    2021-02-05 20:10

    For historical reasons, nearly all browsers (except Opera) prepend Mozilla/ to their user agent.

    For example, here are some common user agents:

    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko)
                Chrome/12.0.742.112 Safari/534.30                    # Chrome 12
    Mozilla/5.0 (X11; Linux x86_64) Gecko Firefox/5.0                # FF 5
    Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)        # IE 9
    Opera/9.80 (Windows NT 5.1; U; en) Presto/2.8.119 Version/11.10  # Opera 11.10
    

    For a detailed list, refer to online databases.

提交回复
热议问题