Patrick Desjardins Blog
Patrick Desjardins picture from a conference

Accessing input control of a parent inside a child frame?

Posted on: 2011-11-19

Not long time ago, I had to modify a code which was using a Frameset with Frame.

I had an issue because the code was written for Internet Explorer only and it was accessing the hidden field by using parent.window.document.myhiddenfield.value.

My first reflex was to remove the window and use getElementById. Like this:

parent.document.getElementById('myhiddenfield').value 

This doesn't work with Firefox either. After some search, I found that we can use self.ownerDocument. Like this:

self.ownerDocument.getElementById('bar'); 

Unfortunately, this doesn't work with Internet Explorer, just Firefox.

My last try was to use JQuery, which solve most of the compatibility problem.

This is the current implementation that works to get hidden input control (or any other input) from a child frame to a parent that hold the frameset.

parent.$("#myhiddenfield").val()