|
|
|
Setting TimeOut is not good idea - speaking generaly you don't really know when the page will be ready.
One option could be registering event handler for the body.onload event either at the BODY start tag, or in your script with document.body.onload += your_function_here;
Or, as you say using 3rd parties - for example jQuery has the beautiful:
$(document).ready(function(){
// your function body here
// and you are 100% sure that
// this function will be executed
// when the entire DOM is populated
}
Anton Staykov |
Homepage |
08.12.08 - 3:25 pm | #
|
|
I totaly agree. That is why I wrote that I do not recomend it. It is still a solution though.
What if you do not have this fance jQuery for example 
Martin Kulov |
Homepage |
08.12.08 - 5:06 pm | #
|
|
Almost every Javascript framework has onDomReady event, however if you do not use such the simple solution is to put the call to the function at the bottom of the HTML (before the closing body tag). This means that when the function is called the DOM tree is built
Peter Velichkov |
Homepage |
08.15.08 - 4:13 am | #
|
|
Thanks Peter,
the javascript is generated in control buried deep down in ASP.NET control hierarchy. Putting it at the end of the document is not an option.
Is there a way to handle the onDomReady event with the MS AJAX framework?
Martin Kulov |
Homepage |
08.15.08 - 7:32 am | #
|
|
http://weblogs.asp.net/stephenwa...ion-
events.aspx
here at the bottom of the article there are two ways suggested:
1. Dean Edwards onDomReady function
2. Using ScriptManager
Peter Velichkov |
Homepage |
08.15.08 - 8:30 am | #
|
|
Thanks,
very nice article!
Martin Kulov |
Homepage |
08.18.08 - 11:13 am | #
|
|
Commenting by HaloScan
|