1

How can I get all the page HTML as String, including the iframe's inside the body?

I tried following,

document.getElementsByTagName('html')[0].innerHTML

But the iframe's HTML is not returned.

Ishara Madhawa
  • 3,549
  • 5
  • 24
  • 42
t1daz
  • 140
  • 1
  • 13
  • From my limitied understanding, you cannot access a cross domain iframe's inner body. Otherwise, `document.getElementById('iframe-id').contentWindow.document` will give you the inner contents of the iframe. You will need to first get the main html and then extract the individual iframes html separately – Chirag Ravindra Apr 17 '18 at 11:34
  • Possible duplicate of [How to get the body's content of an iframe in Javascript?](https://stackoverflow.com/questions/926916/how-to-get-the-bodys-content-of-an-iframe-in-javascript) – Matheus Cuba Apr 17 '18 at 11:43
  • yes @MatheusCuba, right now i'm using the same approach and looking for each iframe. – t1daz Apr 17 '18 at 11:49

1 Answers1

1

You can get iframe's innerHTML with the window.frames object:

window.frames['some-iframe'].document.body.innerHTML 

Good luck!

Pistolpete .
  • 1,118
  • 1
  • 8
  • 17