tags:

views:

51

answers:

1

Hi,

I wanted to know how do I intercept a DOM access by a JavaScript. Are there any tools or whitepapers available on this ? (Else I will need to write one!)

The idea behind the interception is something to do with a security module for web browsers.

Thanks.

+1  A: 

The best you can do is use DOM mutation events. There are various events such as DOMNodeInserted, DOMNodeRemoved, DOMAttrModified etc (see the DOM events spec, linked to above). There is a general catch-all event called DOMSubtreeModified that is fired after any individual DOM mutation; this event bubbles, so you can set a listener on the document to be notified of all changes to the document's DOM.

document.addEventListener("DOMSubtreeModified", function(evt) {
    console.log("DOM mutation", evt);
}, false);

These events are supported in most recent browsers, with the exception of IE (up to and including version 8).

Tim Down