C
cmay
I have recently been working with RegisterStartScript in my asp.net
pages.
However, as you probably know it places the script at the end of the
FORM tag.
However, when this code executes on the client, there is no guarantee
that the document has finished loading, and that the DOM is ready to be
accessed.
In other words, people typically use the body tags onload event to kick
off their init code rather than putting the script at the bottom of the
page because if you have large HTML document and you try to execute the
code document.getElementByID("asdf") and the DOM has not finished
loading (readState <> "completed") then this will thrown an error.
Has anyone else had this problem, or seen any mention of the issue by
Microsoft?
I wrote a workaround that uses setTimeout to keep checking for the
document to finish loading before it runs all my init code, but it is
kind of a pain, and the fact that I don't see any other mentions of
this issue make me wonder if there is something else that can be done,
or if I am doing something wrong.
pages.
However, as you probably know it places the script at the end of the
FORM tag.
However, when this code executes on the client, there is no guarantee
that the document has finished loading, and that the DOM is ready to be
accessed.
In other words, people typically use the body tags onload event to kick
off their init code rather than putting the script at the bottom of the
page because if you have large HTML document and you try to execute the
code document.getElementByID("asdf") and the DOM has not finished
loading (readState <> "completed") then this will thrown an error.
Has anyone else had this problem, or seen any mention of the issue by
Microsoft?
I wrote a workaround that uses setTimeout to keep checking for the
document to finish loading before it runs all my init code, but it is
kind of a pain, and the fact that I don't see any other mentions of
this issue make me wonder if there is something else that can be done,
or if I am doing something wrong.