Reputation: 6217
what i need to do is that i want a Pdf of a book that is on google books. each page of a book is coming through AJAX. but google provides iframe too this is iframe of one i am looking for
<iframe id="iframeId" frameborder="0" scrolling="no" style="border:0px" src="http://books.google.com.pk/books?id=KOrTwnwcJ9IC&lpg=PP1&dq=magento%20books&pg=PT36&output=embed" width=500 height=500></iframe>
i want to grabe all the contents of this book put it in some div and than make a Pdf of it.i can do all but i just can't grab the contents
i tried this but saying id is not defined
<Script type="text/javascript">
var doc;
if (document.getElementById(iframeId).contentDocument) {
doc = document.getElementById(iframeId).contentDocument;
}
else if (document.getElementById(iframeId).contentWindow) { // older IE
doc = document.getElementById(iframeId).contentWindow.document
}
if (doc) { alert(doc.body.innerHTML) }
</script>
in orignal iframe tag there was not id so than i manually write id for iframe tag that is id="iframeId" but not working any idea ??
Upvotes: 1
Views: 731
Reputation: 5647
As long as the page loaded in the iframe is in the same domain you can have something like:
var myIFrame = document.getElementById(iFrameName);
var content = myIFrame.contentWindow.document.body.innerHTML;
But Google also provides support for retrieveng info from google docs in JSON format:
https://developers.google.com/gdata/samples/spreadsheet_sample?hl=ro
And the second might be what you are looking for.
Upvotes: 1