Javascript object window navigator browser name. navigator, screen, and location objects - Browser and screen resolution information - Current URL

An object navigator is used to access the Web browser program itself. Don't confuse it with an object window, which represents the current Web browser window, and the name of the Netscape Navigator program.

appCodeName

Returns the code name of the Web browser program. And for Internet Explorer, and for the Navigator it will return the string "Mozilla". Fucking.

appMinorVersion

Returns the minor digit of the version number of the Web browser program. For example, for Internet Explorer 5.0 it will return "0" and for 5.5 it will return "5".

Only Internet Explorer starting from 4.0 is supported

appName

Returns the name of the Web browser program, such as "Netscape" or "Microsoft Internet Explorer".

appVersion

Returns the version of the Web browser program.

browserLanguage

Returns the code of the Web browser program.

cookie enabled

Returns true if the Web browser is allowed by the user to accept cookies. Supported only by IE starting from 4.0

cpuClass

Returns the processor class client computer, such as "x86" or "Alpha". Supported only by IE starting from 4.0

language

Returns the language code of the Web browser program. Only NN supported since 4.0

online

Returns true if the client is currently connected to the Internet (on-line) and false if it is disconnected (off-line).

Supported only by IE starting from 4.0

platform

Returns the name of the client platform, such as "Win32".

systemLanguage

Gets the language code of the client's operating system. Supported only by IE starting from 4.0

userAgent

Returns a string that identifies the client's Web browser. Is a combination of appCodeName and appVersion property values.

userLanguage

Same as browserLanguage.

Supported only by IE starting from 4.0

An object navigator also supports the method javaEnabled(), which returns true if the Web browser is allowed by the user to execute JavaScript scripts.

I would like to say a little more about the property appVersion, or rather about the value it returns. The thing is that for IE and NN it will be different.

Here's what the Navigator will look like:

(Version) [(Language)] ((Operating System); U|I)

Here (Version) represents the version of the web browser, (Language)- program language (but may be absent), (Operating system)- designation of the client's operating system, for example, "Win96", "Win16" or "WinNT", the letter "U" is the American version of the program, and "I" is the international one.

For example:

4.0 (Win95;I)

Internet Explorer has a property value output format appVersion another:

(Compatible version of Navigator) (compatible; (Version); (Operating system))

Here (Operating system) can be "Windows 3.1", "Windows 3.11", "Windows 95", or "Windows NT".

2.0 (compatible; 3.01; Win95)

Property userAgent returns a value with the format:

(appCodeName value)/(appVersion value)

That is, for the two previous examples, we get the following values:

Mozilla/4.0 (Win95; I) Mozilla/2.0 (compatible; 3.01; Win95)

The navigator object contains information about the user's browser (in particular - is it available to use cookies and is Java support enabled).

The navigator object also allows you to determine the type of operating system.

For the convenience of working with the navigator object, let's display all its properties on the screen. We recall the material from the previous lesson.

Browser information - userAgent property;

Browser language - property language ;

The name of the operating system is a property of oscpu ;

Whether cookies are enabled - property cookieEnable d;

Whether the user is connected to the Internet - onLine property.

Accessing object properties navigator is carried out through a dot.

The screen object will help you get data about the user's screen resolution, color depth, etc.

Let's do the same with the screen object: first, display all its properties on the screen.

Now, using the height and width properties of the screen object, we get information about the screen resolution - its height and width in pixels. And also about the bit depth of the color palette - the colorDepth property.

location object returns the url current user window.

It also contains data about parts and components of the current address: host name, port number, protocol, etc.

Object properties location.

Let's use the href property of the location object to display the URL of the current document.

Let's do our homework for this lesson.

Find out from which browser the person came to your page and, depending on the browser, display on the screen:

If firefox: "Your Firefox browser."
If opera: "Your browser is Opera."
If chrome: "Your Chrome browser."

To complete this homework assignment,:

Use the userAgent property of the navigator object to get information about the current browser.

At the time of solving this problem, I received the following data about Firefox browsers, Opera and Chrome.

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox /56.0

Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome /61.0.3163.100 Safari/537.36 OPR /48.0.2685.39

Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome /61.0.3163.100 Safari/537.36

Find browser names using regular expressions from information about them.

Computer