I'm trying to populate the id="review" tag in the html body with the contents of the iframe (using google as an example page). Instead of the contents of the iframe it returns this: [object HTMLDocument] . What am I doing wrong?
function googleReview()
{
var iframeWindow = document.getElementById('google_window').contentDocument;
document.getElementById("review").innerHTML=iframeWindow;
}
</script>
</head>
<body>
<iframe width="300px" height="80px" frameborder="0" scrolling="yes" name="google_window" id="google_window" src="http://google.com"></iframe>
<p id="review">Review Area</p>
<button type="button" onclick="googleReview()">Change Review</button>
I don't think you can do that; when I add iframeWindow.innerHTML
to get the contents I get a permission denied error. The issue is you're trying to access cross origin (domain) information .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.