--
Joe Fawcett (MVP - XML)
I want to be notified by the DOM, when it about to add elements.
"Joe Fawcett" <joefa...@newsgroup.nospam> 写入消息
news:OSVa17$3IHA...@TK2MSFTNGP06.phx.gbl...
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
"susan" <none> wrote in message
news:BF22A9AC-692C-4598...@microsoft.com...
Joe.
> I want to be notified by the DOM, when it about to add elements.
>
Please don't top-post. Reply inline-style:
http://en.wikipedia.org/wiki/Posting_style#Inline_replying
> "Joe Fawcett" <joefawc...@newsgroup.nospam> 写入消息news:OSVa17$3IHA...@TK2MSFTNGP06.phx.gbl...
>
> > "susan" <none> wrote in message
> >news:8D8827F9-B075-442D...@microsoft.com...
> >>I want to know every event about add element after document has been
> >>completed.
> >> Is there a such events?
Yes. DOMNodeInserted and DOMSubtreeModified would work.
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MutationEvent
addEventListener("load", addMutationEvents, false);
function addMutationEvents(e) {
document.addEventListener("DOMNodeInserted", function(e) {
alert(e.relatedNode);
}, false);
}
Try and see if your browser supports:-
javascript:document.addEventListener("DOMNodeInserted", function(e)
{alert(e.relatedNode);},
false);void(document.body.appendChild(document.createElement('div')))
IE7 and IE8b1 don't support any of DOM Events.
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MutationEvent