It's a Google browser, but Mozilla appears on browserName.

Asked 2 years ago, Updated 2 years ago, 300 views

var name=navigator.appName;
console.log(name)

I wrote the javascript code and ran it on Google browser, and it said Mozilla.
Is this correct?Is there something wrong?

javascript html

2022-09-30 21:53

2 Answers

In Internet Explorer 11, Microsoft Edge, Google Chrome, and Mozilla Firefox, "Netscape" was displayed.
It is recommended that you do not refer to this value unless you need it specifically.


2022-09-30 21:53

It is correct that "Mozilla" is displayed on Chrome.And there is a historical reason for this.

The result returned by navigator.appName is probably based on the value in the User-Agent header, but there was a time when the site was sorting out the process based on whether or not it contained the Netscape code name "Mozilla.
(Only some browsers will receive preferential treatment)

To avoid this problem, many browsers now include Mozilla (compatible).

The User-Agent is not very reliable information because it can be easily disguised in many ways.

reference:
User Agent - Wikipedia


2022-09-30 21:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.