How can I access the content of an iframe with jQuery? I tried doing this, but it wouldn't work:
iframe content: <div id="myContent"></div>
jQuery: $("#myiframe").find("#myContent")
How can I access myContent
?
Similar to jquery/javascript: accessing contents of an iframe but the accepted answer is not what I was looking for.
You have to use the
contents()
method:Source: http://simple.procoding.net/2008/03/21/how-to-access-iframe-in-jquery/
If iframe's source is an external domain, browsers will hide the iframe contents (Same Origin Policy). A workaround is saving the external contents in a file, for example (in PHP):
then, get the new file content (string) and parse it to html, for example (in jquery):