Reputation: 4189
From the Firebug JavaScript console is it possible to access the content of an <iframe>
object whose src
property is set to about:blank
?
I've tried with:
var b=document.getElementById("iframe_ID");
console.log(b.innerHTML);
but it returns
(an empty string)
Upvotes: 0
Views: 1926
Reputation: 20085
With document.getElementById("iframe_ID").innerHTML
you just get the HTML content within the iframe element of the current document, not the iframe's document. I.e. if you have your iframe defined like this:
<iframe src="someDocument.html" id="iframe_ID"></iframe>
you get the contents between the opening <iframe>
tag and the closing </iframe>
tag, i.e. an empty string in this case.
To access the iframe's content you need to call this:
document.getElementById("iframe_ID").contentDocument.documentElement.innerHTML
See also Accessing the document object of a frame with JavaScript.
Though note that there are some security restrictions when trying to access the iframe's content as described in an answer to a similar topic.
Upvotes: 1