diff --git a/js/utils/platform.js b/js/utils/platform.js index df9b3a7a45..d81f3871b4 100644 --- a/js/utils/platform.js +++ b/js/utils/platform.js @@ -351,7 +351,8 @@ var platformName = null, // just the name, like iOS or Android platformVersion = null, // a float of the major and minor, like 7.1 - readyCallbacks = []; + readyCallbacks = [], + windowLoadListenderAttached; // setup listeners to know when the device is ready to go function onWindowLoad() { @@ -364,8 +365,17 @@ // cordova/phonegap object, so its just a browser, not a webview wrapped w/ cordova onPlatformReady(); } - window.removeEventListener("load", onWindowLoad, false); + if (windowLoadListenderAttached){ + window.removeEventListener("load", onWindowLoad, false); + } } + if (document.readyState === 'complete') { + onWindowLoad(); + } else { + windowLoadListenderAttached = true; + window.addEventListener("load", onWindowLoad, false); + } + window.addEventListener("load", onWindowLoad, false); function onPlatformReady() {