ASK Question

Quick links:
Latest articles
Internship
Members

Languages:
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL

Web:
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.

Programs:
C
C++
DS
Java
C#
Python


Aptitude:
C
C++
Java
DBMS

Interview:
C
Embedded C
Java
SEO
HR

CS Subjects:
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS

More:
Articles
Puzzles
News/Updates


Home » JavaScript

Get browser details through JavaScript



In this article, we will create a program to get browser details through JavaScript. It can be accessed through the 'navigator' object that contains all the details. In this article, we will create a program to get browser details through JavaScript.
Submitted by Abhishek Pathak, on November 03, 2017

The web is accessed through Browser. There are a number of browsers available online that has different features but at the core, provide us the medium to access Websites. Different browsers have different internal implementations and this information is accessible to the website through JavaScript.

It can be used to get various information about user such as his language. The browser information can be used to provide access only to particular kind of browser. It can be accessed through the navigator object that contains all the details. In this article, we will create a program to get browser details through JavaScript.

1) Browser Language

The default language that user has set for the browser. It can be accessed via the navigator.language object property. Here's an example.

Code

var language = navigator.language;
console.log('Your default language is ' + language);

//Output: Your default language is en-US

2) Browser Name

The browser name can be accessed by navigator.userAgent object property. But here's a catch, most of the browsers use the same userAgent name as they have same implementations at the core level. It primarily consists of Mozilla, Safari and Chrome.

Code

var browser = navigator.userAgent;
console.log('Your browser is ' + browser);

Output

Your browser is Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36


3) Is Java Enabled?

We can also check using JavaScript that if Java is enabled in browser by the navigator.javaEnabled() object method which returns true is Java is enabled in the browser.

Code

var java = navigator.javaEnabled();
if(java) {
	console.log('Java is enabled');
} else {
	console.log('Java is not enabled');
}

With JavaScript getting browser details is easy and it can be useful for your program. Hope you like the article; please share your thoughts and comments below.






Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.