1.11M Members

Detect Browsers and Operating Systems using javascript

 
0
 

Hi
Is ther anothe easy way to detect browser used and versions and Operating system via javascripts?

I appreciate your help

 
0
 

The user-agent string contains the information you need. Using JavaScript you can access it through the browser's navigator object, e.g. navigator.userAgent.

 
0
 

Thanks sir
It seems not work for me

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Inform about user browser and Os</title>

<body>
<button id="display" onclick="myFunction()">Detect User browser and Operativ system</button>



<script>
    function myFunction()
    {
        var x = "User-agent header sent: " + navigator.userAgent;
        document.getElementById("demo").innerHTML=x;





    }
</script>
</body>
</html>
 
0
 

Line 16, document.getElementById("demo") is returning null. There is no element with the ID demo.

Insert something like <p id="demo"></p> at line 11 and you should find it'll work.

 
0
 

Thanks Sir
Its work
What about detecting operation system?Have you any idea?

 
0
 

You simply need to parse the string. So for example...

Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36

In this string, you can tell that the user is running Windows 8.1 because "Windows NT 6.3" indicates that the OS is Windows 8.1

 
0
 

Thanks Sir
Now Im understand it.

Question Answered as of 6 Months Ago by LaxLoafer and JorgeM
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: