Search code examples
javascriptcordovaratchet

window.onload() is not firing in hybrid app


this following code is working in the browser on my PC, but not in my hybrid app built with cordova. I'm using the ratchet framework.

<script type="text/javascript">
        window.onload = function () {

            document.getElementById('cy_username').value = localStorage.getItem('cy_username');
            document.getElementById('cy_password').value = localStorage.getItem('cy_password');

            document.getElementById('settingsForm').addEventListener('submit', onFormSubmit, false);

            if (localStorage.getItem('cy_pushNotification') == "true") {
                document.getElementById('cy_pushNotification').classList.add('active');
            }
            if (localStorage.getItem('cy_emailNotification') == "true") {
                document.getElementById('cy_emailNotification').classList.add('active');
            }

            showInfoBox();
        }
    </script>

Solution

  • window.load is only for desktop browser, for hybrid application use,

    document.addEventListener("deviceready", function() {
    
    }, false);