Q:

The Javascript window navigator browser name doesn't work in chrome

It is said that we can use javascript navigator function to get all the browser related properties of a machine.  I had tried to get the same here as,
<! DOCTYPE html>
<html>
  <body>
    <p id="demo"></p>
    <script>
      document.getElementById("demo").innerHTML =
        "Name is " + navigator.appName +
        "<br>Code name is " + navigator.appCodeName;
    </script>
  </body>
</html>

to get the browser name.  But when I open it in chrome, the navigator.appName gives as Mozilla.  So how can I get the app name as chrome? 

A:

I please use below codes to check your browser name
    function myFunction() { 
    if((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) ! = -1 ) {
        alert('Opera');
    } else if(navigator.userAgent.indexOf("Chrome") ! = -1 ) {
        alert('Chrome');
    } else if(navigator.userAgent.indexOf("Safari") ! = -1) {
        alert('Safari');
    } else if(navigator.userAgent.indexOf("Firefox") ! = -1 ) {
        alert('Firefox');
    } else if((navigator.userAgent.indexOf("MSIE") ! = -1 ) || (!! document.documentMode == true )) {
        alert('IE'); 
    } else {
        alert('unknown');
    }
} 

I think that may help you. 
Thanks

