Home » Web » Javascript » Accessing input control of a parent inside a child frame?

Accessing input control of a parent inside a child frame?

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()

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.