It is best to set up an event listener in the function after the document has finished loading. Try something like this:
<body onload="onLoad()">
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
or using jquery:
$(document).ready(function() {
document.addEventListener("deviceready", onDeviceReady, false);
});
source
share