I am new to JavaScript and having a slight issue figuring out when events fire. Here is the situation. I am writing an ASP.Net application. In my code behind, in the Page_Load() I have some code. I need this code to execute first. After this code has finished executing, then I need my JavaScript to execute.
Is there an event or something that exists that insures the code will execute in that order?
The simplest way would be to add your function call to your body’s onload event
Alternatively, you could also place some script at the very end of your body. Any script in here will be executed after the body is processed. You’ll be able to do things like
without it coming back as null.
EDIT
I didn’t see jQuery tagged on your question, but, if you happen to be using it, you can also do this:
or more simply: