What is Navigator – Troubleinthepeace

In this self-taught JavaScript tutorial, you’ll learn about navigator properties in windows


1. What is Navigator?

Attribute navigator in window (it mean window.navigator) is a reference to an object Navigator.

You are viewing: What is Navigator?

It is a read-only property that contains information about the user’s browser.

Because window is a global object and it is on top of the scope chain, so properties of Window objects like window.navigator can be accessed without the window prefix.

For example window.navigator.language can be written as navigator.language.

In the next section you will learn how to use the navigator property to get various information about the user’s browser.

2. Detect if the browser is online or offline

You can use the attribute navigator.onLine to detect whether the browser (or, application) is online or offline.

This property returns the value true means online or false means offline.

Checking connection

The browser fires online and offline events when an internet connection is established or lost.

Based on that result, you can add handler functions to these events to customize your website/app for the right online and offline scenarios.

3. Check if cookies are enabled?

You can use navigator.cookieEnabled to check if cookies are enabled in the user’s browser.

This property returns the value true if cookies are enabled or false if not.

Check Connection Cookies

Tip: You should use the attribute navigator.cookieEnabled to determine if cookies are enabled before creating or using cookies in your JavaScript program.

4. Detect browser language

You can use the attribute navigator.language to detect the language of the browser the user is using.

This property returns a string representing the language, e.g. “en”, “en-US”, etc.

Language test

5. Get information about browser name and version

Subject Navigator There are five main properties that provide name and version information about the user’s browser.

See also: What is Olymp Trade – The Most Detailed Review of Olymp Trade

Try an example below:

Get browser information

Try running it in your browser and see how it goes.

Description of properties:

+ appName – Returns the name of the browser. It always returns “Netscape”, in any browser.

+ appVersion – Returns the version number and other information about the browser.

+ appCodeName – Returns the browser’s codename. It returns “Mozilla”, for all browsers.

+ userAgent – This property usually contains all the information in both appCodeName and appVersion.

+ platform – Returns the platform on which the browser is running (e.g. “Win32”, “WebTV OS”, etc.)

As you can see when you run the example, the value returned by these properties is skewed and unreliable. Therefore, you should not use it to get information about what the user’s browser does.

6. Check if your browser has Java enabled

You can use the method javaEnabled() to check if the current browser supports Java.

> Reference: JAVA WEB COURSE (Full Stack) if you love Java language and want to develop long term with it.

This method simply indicates whether the Java control option is ON or OFF.

Check if Java is enabled

It does not reveal to us whether the browser provides Java support or if Java is installed on the user’s system.

> And don’t forget, if you want to learn web programming methodically and become a profession, then FULL STACK PROGRAMMING COURSE This is a best option.

Student opinion

The knowledge I have learned at NIIT – ICT Hanoi gives me a great advantage for the Marketing job at VTC Mobile that I currently pursue. Wish NIIT – ICT Hanoi more and more developed ^^.

See also: What is IQf – Eastern Level Conveyor System

Tran Ngoc Quynh – Marketing – VTC Mobile

I find that the quality of training is always valued by NIIT – ICT Hanoi. What I learned here is how to think like a programmer and apply IT to do what I love.

Nguyen Thanh Luan – Graphics Designer at Reface Studio

My time studying at NIIT – ICT Hanoi has helped me grow up a lot. Currently, the coding career is also quite smooth. Wish you all the best in your next class!


About Troubleinthepeace

Troubleinthepeace specializing in synthesizing information about daily life activities

View all posts by Troubleinthepeace →

Trả lời

Email của bạn sẽ không được hiển thị công khai.