I would like to implement a way in javascript
to check if a user is viewing the document in IE, Mozilla or Chrome. The reason is because the key event trigger behaves differently in different browser. Thus, if I can detect what sort of browser, I can work around this issue. I just want to know what type of browser, not what browser version is being used.
From what I have researched, it seems I have to use some sort of library call navigator.userAgent
. I'm unfamiliar with this since this is new to me.
Link: How to detect Safari, Chrome, IE, Firefox and Opera browser?
The idea of what I want to implement goes like this:
if(user detected using Firefox)
function1()
if(user detected using Chrome)
function2()
if(user detected using IE)
function3()
.....
What is the proper way to use this library or is there any other way to detect the browser type?