Skip to content

Instantly share code, notes, and snippets.

@RhinoLance
Created September 17, 2013 06:38
Show Gist options
  • Save RhinoLance/6590770 to your computer and use it in GitHub Desktop.
Save RhinoLance/6590770 to your computer and use it in GitHub Desktop.
DeviceReady call for Cordova / Phonegap
$(document).ready(function () {
if (document.URL.indexOf('http://') === -1 && document.URL.indexOf('https://') === -1) {
document.addEventListener("deviceready", OnLoad, true);
}
else {
OnLoad();
}
});
@RhinoLance
Copy link
Author

An alternative:

document.addEventListener(location.scheme == 'file:' ? 'deviceready' : 'DOMContentLoaded', OnLoad, true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment