[英]The best way to call onload function for android in phonegap
How can I call to Onload function when the app is run on device? 当应用程序在设备上运行时,如何调用Onload函数? On browser this line ... working well, but when I run my app on android device the onLoad function not calling, whan can I do to make the
onload
call? 在浏览器这一行...运作良好,但是当我的Android设备上运行我的应用程序在onLoad功能没有要求,我焕能做到,使
onload
电话吗?
I have tried to add this code in the tag inside of the "<body onload="onLoad">... </body>"
code : 我尝试将这段代码添加到
"<body onload="onLoad">... </body>"
代码的标记中:
<head>
// ....
<script>
document.addEventListener('deviceready', onLoad);
</script>
<script type="text/javascript" src="js/help.js"></script>
<script type="text/javascript" src="cordova.js"></script>
</head>
<body>
</body>
help.js: help.js:
function onLoad()
{
window.alert("onLoad");
}
onLoad- is the function that I write in my help.js file, and I add this file inside script tag. onLoad-是我在help.js文件中编写的函数,并将此文件添加到script标签内。 On my android device nothing the alert not show.
在我的android设备上,没有任何警报未显示。
Unclear from your snippet but you may need to include cordova.js in your HTML body in a script tag if you aren't doing so already. 尚不清楚您的代码段,但如果您尚未这样做,则可能需要在脚本标记的HTML主体中包含cordova.js。 Cordova CLI will make sure that file gets to where it needs to be when building for a device:
Cordova CLI将确保在构建设备时文件到达所需的位置:
<script type="text/javascript" src="cordova.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.