views:

27

answers:

1

Hi All,

I want to intercept DOM object read and write queries fired by JS while getting loaded by the browser. After intercepting these calls, i wish to screen them. I have written the logic for screening but am not able to block the calls.

Is there any way other than modifying source code of the browser to achieve this? If so pls help me.

Your effort is appreciated.

Thanks in advance.

A: 

You mean like this? (for some reason fails in Fx with illegal operation)

<script>
var oldGet = document.getElementById;
document.getElementById=function(id) {
  return confirm('Someone wants to know about '+id+', is that ok?')?oldGet(id):null;
}
window.onload=function() {
  alert(document.getElementById('div1').innerHTML);
}

</script>
<div id="div1">Hello</div>
mplungjan
People who down-vote really aught to say why!
mplungjan
No. I dont want to do it this way. I need a separate tool independent of the browser to scrutinize DOM access.
Praveen
That is called a debugger, no? Firebug for example
mplungjan
Firebug, as a debugger allows you to place breakpoints and debug the JS code. What am trying to do is a security tool which will screen DOM access to prevent cross site scripting attacks. I want to have a separate tool which has the logic which i have proposed for screening DOM access. It will allow or deny any DOM access by third party JS code in a web page based on permissions set.
Praveen
Have you had a look at writing a plugin/extension? Or perhaps you can hook into "watch" http://james.padolsey.com/javascript/monitoring-dom-properties/
mplungjan