How can I call to Onload function when the app is run on device? 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?
I have tried to add this code in the tag inside of the "<body onload="onLoad">... </body>"
code :
<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:
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. On my android device nothing the alert not show.
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. Cordova CLI will make sure that file gets to where it needs to be when building for a device:
<script type="text/javascript" src="cordova.js"></script>
window.alert
works in browser and not in android.
you should use notification.alert
as explained here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.