jQuery

Accessing iFrame content from parent HTML page using jQuery

I got stuck on this one once, so I decided to write my own article.

To access the content of any iframe on your html page, you can use following:

$('#frameID').contents().find('#someElement').html();

Note, both iframes must be hosted on the same domain, otherwise you will get error, similar to this one:

Error: Permission denied for <http://localhost> to get property HTMLDocument.nodeType from <http://www.example.com>.

Neat workaround for this issue is described on Michael Mahemoff's blog, in article Cross-Domain Communication with IFrames.

Syndicate content