Check whether browser exists or not?

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 201
Write below code:-
function BrowserExists() 
{
//Check if browser is IE or not
if (navigator.userAgent.search("MSIE") >= 0) {
alert("Browser is InternetExplorer");
}
//Check if browser is Chrome or not
else if (navigator.userAgent.search("Chrome") >= 0) {
alert("Browser is Chrome");
}
//Check if browser is Firefox or not
else if (navigator.userAgent.search("Firefox") >= 0) {
alert("Browser is FireFox");
}
//Check if browser is Safari or not
else if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
alert("Browser is Safari");
}
//Check if browser is Opera or not
else if (navigator.userAgent.search("Opera") >= 0) {
alert("Browser is Opera");
}
}

Comments or Responses

Login to post response