我正在寻找一种方法来检测下载页面的操作系统,使用 jQuery 或 Javascript 来推荐适用于 Mac 和 Windows 的特定文件.我希望在不向我的页面添加另一个插件的情况下做到这一点.
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 another plugin to my page.
试试:
var os = navigator.platform;
然后根据结果相应地处理 os 变量.
Then handle the os variable accordingly for your result.
您还可以遍历 navigator 对象的每个对象,以帮助您更熟悉这些对象:
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>
这篇关于jQuery/Javascript 在没有插件的情况下检测操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 javascript 认为文档“准备好"之前,如何让How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 认为文档“准备好
jasmine 运行和等待实际上是做什么的?What do jasmine runs and waitsFor actually do?(jasmine 运行和等待实际上是做什么的?)
如何提供模拟文件来更改 <input type='filHow to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模拟文件来更改 lt;input type=filegt; 的事
如何使用 Jasmine 对链式方法进行单元测试How to unit test a chained method using Jasmine(如何使用 Jasmine 对链式方法进行单元测试)
如何将 $rootScope 注入 AngularJS 单元测试?How do I inject $rootScope into an AngularJS unit test?(如何将 $rootScope 注入 AngularJS 单元测试?)
Jasmine - 如何监视函数中的函数调用?Jasmine - How to spy on a function call within a function?(Jasmine - 如何监视函数中的函数调用?)