[英]document.addEventListener('keydown', console.log(“test”)); not working as expected
[英]Console.log and document.addEventListener is not working
我正在尝试在IOS中创建一个phonegap应用程序。 我已经成功创建了该项目,当运行相同的应用程序时,它运行良好,当更改为我的代码时,它未检测到除alert()之外的任何JavaScript事件。
document.addEventListener('deviceready', function(){}, false);
console.log("I'm working");
这些功能在Xcode和iOS设备或仿真器中不起作用。
我创建的相同应用程序在android中工作正常。
请帮助我解决此问题。
我无法开始猜测为什么它可以在Android而不是iOS上运行。 您确定要包含在html页面的标题中吗? 没有它,“ deviceready” listiner将无法工作。 其他一切看起来都不错。 phonegap文档显示以下代码:
<!DOCTYPE html>
<html>
<head>
<title>Device Ready Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// device APIs are available
function onDeviceReady() {
// Now safe to use device APIs
****For testing purposes, add an alert() here to ensure it is working.****
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.