2

this is my part of code now i'm using iframe tag and loaded epub on iframe tag then i don't know how to get all elements inside iframe tag.

jQuery(document).ready(function($) {
  var tmp = $('#epub_loader iframe').contents().find('body').html();
  alert(tmp);
});
<iframe id="epub_loader" href="test.epub" ></iframe>

`

naren
  • 69
  • 9

2 Answers2

0

Assuming both your frames are on the same domain and there is no restriction with Same Domain Policy, you can use the following code from the "parent" frame to get an element in the "child" iframe (in your case body tag).

Pseudo code, you need to actually point to your iframe DOM by id:

var html = document.getElementById('iframe').contentDocument.body.innerHTML;

Notes: In case iframe is on a different domain, you have limited access for browser security reasons.

GibboK
  • 71,848
  • 143
  • 435
  • 658
0

The thing you need is to wait document will be fully loaded coz you are used iframe,then you should call ....

jQuery(document).ready(function() {
  window.onload = function () {  //call when iframe is fully loaded
  var tmp = $('#epub_loader').contents().find('body').html();
  alert(tmp);
  };
});
Jack jdeoel
  • 4,554
  • 5
  • 26
  • 52