Strange User Agent With Google Chrome

前端 未结 5 1311
礼貌的吻别
礼貌的吻别 2021-02-01 14:38

I was working with some javascript and found a strange user agent with my Google Chrome.

I have Google Chrome 7.0.517.41 beta installed on my Ubuntu Laptop. Now AFAIK my

相关标签:
5条回答
  • 2021-02-01 15:19

    User agent strings are like that, as mentioned.

    You haven't said that explictly, but if you are planning to use useragent string to detect the user's browser, please use some good code to do that (i.e. don't code it yourself in a hurry, you'll not get it right).

    Here is a nice one that I've used a couple times before: Browser detect.

    0 讨论(0)
  • 2021-02-01 15:20

    The UA string tells the long and tragic history of (in)compatibility attempts. See e.g. this for a brief history of the UA. It should also make clear that UA sniffing is useless, as every modern browser pretends to be many other browsers. That is also the case you see here:

    • Mozilla - the most ancient artefact, dating from the early 1990s
    • X11 - the graphical interface used
    • Linux i686 - OS and processor type
    • en_US - your locale (English, United States)
    • AppleWebKit/534.7 - the actual rendering engine
    • (KHTML, like Gecko) - another artifact of browser sniffing: "Gecko" is the FF rendering engine, KHTML is an old rendering engine, predecessor of WebKit (was used by Konqueror browser, than forked by Apple to form WebKit)
    • Chrome/7.0.517.41 - the actual browser version
    • Safari/537 - yet another artifact against scripts sniffing for "Safari" (which uses the same engine)

    In short: some broken sites assumed that "only allowing people with Mozilla/Firefox/Webkit/whatever" is a sensible policy; in turn, browsers started lying about their origins to get around these artificial barriers. The UA strings are the result: bloatware, full of useless garbage.

    0 讨论(0)
  • 2021-02-01 15:20

    Basically, Mozilla stands for "Mozilla compatible" while "KHTML, like Gecko" describes the rendering engine.

    Essentially, Chrome's user agent string is saying "I'm compatible with Mozilla and my rendering engine is like Gecko" as a way of describing itself to developers.

    Most (if not every) browser will identify itself as Mozilla-compatible as a kind of legacy thing, regardless of affiliation with the Mozilla foundation. Yes, even Internet Explorer.

    More info on strings in general at: Mozilla's developer center.

    Also, if you're developing based on user agent strings, don't. You'll only find yourself in a world of hurt: browsers get upgraded to implement features and your user agent sniff might still exclude them, user agent strings can be spoofed, and good old Opera likes to report itself as Internet Explorer in older versions.

    Instead, use feature detection to determine if a feature you're trying to use exists for a given browser and then use it or don't.

    0 讨论(0)
  • 2021-02-01 15:34

    After trying everything I have finally used : http://www.useragentstring.com/

    You can use the above website to get the formatted user agent and OS.
    They have api which you can use directly...

    hope it helps..!!!

    0 讨论(0)
  • 2021-02-01 15:35

    There are historical reasons for browsers "lying" about themselfs. The main reason for this was user agent sniffing. Opera is the only browser which identifies itself as Opera, all other browsers use Mozilla/5.0 or the older ones Mozilla/4.0.

    The only thing you should know about this is: User agent strings cannot be trusted, feautre detection is recommended instead.

    0 讨论(0)
提交回复
热议问题