Forum Moderators: open

Message Too Old, No Replies

attaching event handlers to IFrame documents

anyone ever attach a event handler to an element in an IFrame

         

vibe

9:12 pm on Feb 28, 2006 (gmt 0)

10+ Year Member



Greetings all

Glad to have joined the forum and I look forward to contributing.

Anyone ever attach an event handler to an element in an IFrame?

I have created an IFrame that I can then reference like this

var iDoc = document.getElementById(id).contentWindow.document.body;

them attach a hendler to that element
iDoc.onfocus = function() {
alert("the body has focus")
}

I can access the elements (nodes) and get their properties and attributes. but.... NO I can't seem to assign a handler on anything in the frame

Sincerely
Don T

mrhoo

5:53 am on Mar 5, 2006 (gmt 0)

10+ Year Member



I attach mouse and keyboard event handlers to Iframe elements pretty much the way you have referenced it, but I never tried to catch a focus on a body element.

Start by capturing a 'click' from the body, and go from there.