onload innerhtml

A

Andrew Poulos

I'm modifying the contents of a DIV using innerHTML and after the
modification I need to run some javascript on it. Is there an equivalent
of an onload event I can use with innerHTML?

Andrew Poulos
 
T

Thomas 'PointedEars' Lahn

Andrew Poulos wrot:
I'm modifying the contents of a DIV using innerHTML and after the
modification I need to run some javascript on it. Is there an equivalent
of an onload event I can use with innerHTML?

Counter-question: Is there reason to believe that execution will continue
after the assignment before the content has changed? If no, simply put the
code after the assignment; if yes, it depends on the runtime environment
(RTFM¹). If that environment does not support the event, you need to resort
to property polling with window.setInterval() or, in shorter intervals,
preferably with self-calling window.setTimeout().

That said, you should not be using the proprietary `innerHTML' property, but
standards-compliant W3C DOM Level 2+ methods instead.²


PointedEars
___________
¹ <http://www.w3.org/TR/DOM-Level-3-Events/#events-mutationevents>
<https://developer.mozilla.org/En/Listening_to_events#Simple_DOM.c2.a0events>
<http://msdn.microsoft.com/en-us/library/ms533051(VS.85).aspx>
² <http://www.w3.org/TR/DOM-Level-3-Core/core.html#i-Document>
 

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

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,114
Latest member
GlucoPremiumReview
Top