jQuery/Javascript to detect OS without a plugin?

后端 未结 7 594
余生分开走
余生分开走 2020-11-27 16:40

I am looking for a way to detect the OS for a downloads page using jQuery or Javascript to recommend specific files for Mac vs Windows. I was hoping to do it without adding

相关标签:
7条回答
  • 2020-11-27 17:22

    Try:

    var os = navigator.platform;

    Then handle the os variable accordingly for your result.

    You can also loop through each object of the navigator object to help get you more familiarized with the objects:

    <script type="text/javascript">
    for(var i in navigator){
        console.log(i+"="+navigator[i]+'<br>');
    }
    </script>
    
    0 讨论(0)
提交回复
热议问题