javascriptparentframeattachevent

How can I attach an Event to an element of a parent frame in javascript?


I want to attach an 'onclick' event in a link element in my editor.

I did this:

parent.document.frames["myframe"].document.body.attachEvent('onmouseover', function(e) { 
        parent.document.frames["myframe"].document.getElementsByTagName("a").attachEvent('onclick', function(e) { 
            alert("Hello");
        });
 });

but it doesn't work. I want this one to work in IE and I am using Javascript. Does anyone know what is wrong with it?

Thanks


Solution

  • I did with jQuery finally:

      parent.document.frames["myframe"].document.body.attachEvent('onmouseover', function(e) { 
            $("a",parent.document.frames["myframe"].document).click(function(event){
                 alert("hello");
            });
      });