Jak sprawdzić system operacyjny za pomocą js

<!DOCTYPE html>
<html lang="pl">
<meta charset="UTF-8">
<title>Page Title</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<script> 
    function operatingSytem() { 
        var OSName="Unknown OS";
        if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
        if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
        if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
        if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
          
        document.getElementById("OS").innerHTML = OSName;
    } 
</script> 
<body>
    <button onclick="operatingSytem()"> 
        Pokaż system operacyjny 
    </button> 
  
    <p id="OS"></p> 
</body>    
</html>
Ask ChatGPT
Set ChatGPT API key
Find your Secret API key in your ChatGPT User settings and paste it here to connect ChatGPT with your Tutor LMS website.
Scroll to Top