Javascript code to get the browser information
To get the browser information using JavaScript, you can use the navigator object. This object contains information about the browser and the device that is accessing the web page.
Here is an example of how you can use the navigator object to get the browser name and version:
var browser = navigator.userAgent;
if (browser.indexOf('Chrome') > -1) {
console.log('You are using Chrome');
} else if (browser.indexOf('Firefox') > -1) {
console.log('You are using Firefox');
} else if (browser.indexOf('Safari') > -1) {
console.log('You are using Safari');
} else if (browser.indexOf('Edge') > -1) {
console.log('You are using Edge');
} else {
console.log('Your browser is not recognized');
}This code will check the userAgent property of the navigator object, which contains a string that identifies the browser and version. The code then uses the indexOf method to check for the presence of certain strings that indicate the browser name (e.g. "Chrome" or "Firefox").
You can also use the appName and appVersion properties of the navigator object to get the name and version of the browser.
Latest Post
Information retrieval – Searching of text using Elasticsearch
Information retrieval is the process of obtaining relevant information resources from the collection of resources relevant to information need.
Learn more