[英]Phonegap iOS - device ready not firing other events do
I tried everything but still can't fire the deviceready event. 我尝试了所有操作,但仍然无法触发deviceready事件。 I also tried to fire the pause event which worked OK. 我还尝试触发暂停事件,但工作正常。 I'm using cordova 2.0.0. 我正在使用cordova 2.0.0。 Here is my code: 这是我的代码:
<html>
<head>
<title>Taxiii</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale =1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="stylesheet" href="reset.css" type="text/css" media="all" />
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
<script src="cordova-2.0.0.js"></script>
<script src="jquery.js"></script>
<script src="xui.js"></script>
<script src="iscroll.js"></script>
<script src="loadData.js"></script>
<script src="loadServices.js"></script>
<script src="js.js"></script>
<script src="methods.js"></script>
<script src="setSizes.js"></script>
<script src="map.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?libraries=places,geometry&sensor=true"></script>
<script>
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
alert("123")
}
</script>
</head>
<body onload="onLoad()">
...
I've tried more syntaxes but none worked. 我尝试了更多的语法,但没有一个奏效。
There's no need to wrap document.addEventListener("deviceready", onDeviceReady, false);
无需包装document.addEventListener("deviceready", onDeviceReady, false);
inside function onLoad()
. 内部function onLoad()
。 Try without it and tell if it helped. 尝试不使用它,并告诉它是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.