如何仅在设备基于 iOS 时运行 jQuery 代码
How to run jQuery code only if device is iOS based?
可能的重复项:
检测设备是否为 iOS
这是我想做的:
<script type="text/javascript">
// Run This code if device is iOS based
window.addEventListener('DOMContentLoaded',function() {
$("body").queryLoader2({
barColor: "#37201b",
backgroundColor: "#c2a875",
percentage: true,
barHeight: 5,
completeAnimation: "grow"
});
});
// if it is not iOS run this code
$(document).ready(function () {
$("body").queryLoader2({
barColor: "#37201b",
backgroundColor: "#c2a875",
percentage: true,
completeAnimation: "grow",
barHeight: 5
});
});
</script>
我写什么来让它工作,而不是评论?
jQuery(document).ready(function($){
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i);
if (agentID) {
window.addEventListener('DOMContentLoaded',function() {
$("body").queryLoader2({
barColor: "#37201b",
backgroundColor: "#c2a875",
percentage: true,
barHeight: 5,
completeAnimation: "grow"
});
});
}
else
{
$(document).ready(function () {
$("body").queryLoader2({
barColor: "#37201b",
backgroundColor: "#c2a875",
percentage: true,
completeAnimation: "grow",
barHeight: 5
});
});
}
});
相关文章:
- 无法在iOS模拟器上运行简单的基于KineticJs的Cordova/PhoneGap应用程序
- Meteor应用程序突然不再在iOS上运行
- 如何仅在设备基于 iOS 时运行 jQuery 代码
- 全屏API无法在Chrome/iOS上运行
- 在iOS应用程序的分析云代码上运行crypto-js的问题
- Cordova应用程序在安卓系统上运行,但线程似乎在ios上冻结了;“由于页面加载而重置插件”;
- Phonegap内部版本:应用程序无法在iOS上运行
- removeClass无法在iOS v2上运行
- 运行IOS自动化脚本时需要查找崩溃
- 从运行 JavaScript 中排除 iOS
- 流星运行ios --冗长
- 自动滚动到目标,iOS 中的 jQuery 运行得太远
- Sencha Touch应用程序在Android和iOS上运行良好,但在Windows 8.1上挂起
- 每次加载新页面时,在iOS webView中运行JS
- SimpleWeather.js位置更新无法在iOS设备上运行
- Phonegap简单javascript未运行(onClick问题?)-Android和iOS都有
- Parse.Cloud在iOS上运行缓慢
- FileReader无法在iOS 8上运行
- 使用webkit运行iOS应用程序时延迟选择
- 我的javascript代码在pc上运行,但没有;t在android或ios上运行