views:

25

answers:

1

Hey Gurus,

I am working to use IE Dom interface to automate IE page access. I am trying to get all event handlers defined in a page. I am using IHTMLElement object now for this purpose. If the html page defines "onclick=xxx", element.onclick returns the click handler. However, if an event handler is defined in javascript, element.onclick simply returns NULL. What's the right way to get the event handler then?

Thanks, xin

Below is an example that uses javascript to define event handler.

<!doctype html>
<html>
  <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript"> </script>
  </head>
  <body>
    <script>
      $(document).ready(function(){
        $("a").click(function(event){
          $(this).hide("slow");
          alert("Thanks for visiting!");
          window.location="http://cnn.com";
        });
      });
    </script>
    <a>jQuery</a>
  </body>
</html>
A: 

This is not possible.

SLaks
Thanks for your reply. why isn't it possible? I loaded IE DOM inspector in IE. It is able to detect that the <a> element has a 'jQuery123123="1"' attribute associated. This seems to indicate that it catches something. I don't need to know the detail of the event handler, just want to know whether there is a handler attached or not. Thoughts?
@usfree74: For jQuery, you can query its internal data structures to find the events. (Note that there are three different versions)
SLaks
However, it is completely impossible to find an event registered through `attachEvent`.
SLaks