This question already has an answer here:
I am using following script there, form this script on my page add iframe and I want to get iframe html.
<script src="http://ads.sonobi.com/ttj?id=881134" type="text/javascript"></script>
Problem is in iframe there is inner iframe.
Javascript following function using for get content of ifrmae
document.getElementById('f1').contentWindow.document.body.innerHTML
When I run this will show following error
Permission denied to access property 'document'
How to solve the problem of permission denied.
You can't.
Why? It's a security feature to stop Cross-Site Scripting (XSS) attacks.
For example, you have an iframe that loads
www.facebook.com
. If this security feature wasn't implemented, you could easily fetch data from that site. From cookies, to what content is on the page.There is more helpful information about this here: http://www.veracode.com/security/xss
Try
Source: Frame/IFrame contentDocument Property.
I didn't look at the JS, but you can't get HTML from an remote page with javascript. Try PHP's cURL.