How to access text box values in an iframe?


Im trying to access a string in a textbox which Is located within an iframe on the parent document but the iframe is linked to a source html file.

I know of


But because its within an iframe which is getting its data from another html file Im having difficulty.

Many thanks.

The following one-liner reaches from a child window up to the parent, and in to an iframe to retrieve the content.


Resulting in:

“<p>I am the iframe.</p>”

Breaking it down:

var parentDoc = window.opener.document;
var iframeDoc = parentDoc.getElementsByTagName('iframe')[0].contentDocument;
var iframeContent = iframeDoc.getElementById('content').innerHTML;