detect client browser using javascript

This is the most common situation everyone has faced (If not than you will in future 🙂 ) where you want to detect client browser using javascript and perform some action based on it. For example, I want to display ‘Hello IE user’ message when user is using internet explorer and in case of other than IE browser I want to display ‘Hello other user’.

So how can we achieve this goal ?

Answer for the above question is: Windows Navigator.

You can do it using Windows Navigator object.

What is “Windows Navigator” ?
Windows Navigator object contains information of client’s browser. This navigator object has a property called  which holds information about user-agent header which was sent by browser to the server.

What does “user-agent header” contain ?
It Contains name, version and platform of the browser and it is supported by almost all browsers.

How header looks like? :

 How it can be implemented using Javascript:

So for example I want to detect browser when window is getting loaded than I would write as mentioned below:

you can use it any time instead of window load event.