I am developing an application using PhoneGap and jQuery Mobile.
Now when the page gets loaded then I want to load a script(.js file). Basically onDeviceReady or $(document).ready(). How to do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
http://api.jquery.com/jquery.getscript
http://docs.phonegap.com/en/1.4.1/phonegap_events_events.md.html#deviceready
This second code snippet is a slightly modified version of the Google Analytic code, used to add a script to the DOM asynchronously.
UPDATE
You can also set the
deferattribute of a<script>tag totrueand it won’t be executed until after the DOM has been prepared. See some documentation here: https://developer.mozilla.org/en-US/docs/HTML/Element/Script