control emitting javascript for document.onload

J

JV

If a control needs to execute some client-side script when the document is
loaded, it's easy enough to register a script. Using
RegisterStartupScript() you could emit a script that starts with "<SCRIPT
FOR=window EVENT=onload ...". Unfortunately, this will work only once.
Thus if there is any other script for window.onload (such as when you use
your control twice, for example) only the one that appears last in the HTML
will actually execute.

It's also possible to use RegisterStartupScript() to register some script
code that's not contained in a function so that it just runs toward the end
of the page load process, but at that point the DOM is not completely
finished being loaded, so the script can't do certain things yet.

Am I overlooking something simple? How would you handle this situation?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top