-2
function init() {
    document.getElementById('step1').innerHTML = document.getElementsByTagName('iframe')[0].contentDocument.document.body.innerHTML;
    document.getElementById('code1').value = document.getElementById('google_ads_frame1').src;
    document.technical1.submit();
}

o erro se encontra na linha document.getElementById'step1').innerHTML=document.getElementsByTagName('iframe')[0].contentDocument.document.body.innerHTML;

enter image description here

CoderPi
  • 12,985
  • 4
  • 34
  • 62
  • 1
    For better understanding, Please provide a **working demo** (*code snippet,jsfiddle ...*) – Kishore Sahasranaman Dec 05 '15 at 17:09
  • 1
    Please show us your HTML-Code aswell – CoderPi Dec 05 '15 at 17:39
  • 1
    You can get your problem solved for free by providing enough code here to duplicate the error. Please [edit] your question to include a working demo of your code (the HTML & JS as requested). This is not a site where you pay for help and your offer of money is inappropriate here. – BSMP Dec 05 '15 at 18:29
  • [Even more free](http://stackoverflow.com/questions/14028959/why-does-jquery-or-a-dom-method-such-as-getelementbyid-not-find-the-element) ... no need to even bother to edit the question? – Teemu Dec 05 '15 at 19:31

1 Answers1

0

Use just contentDocument.body instead of contentDocument.document.body:

document.getElementById('step1').innerHTML = document.getElementsByTagName('iframe')[0].contentDocument.body.innerHTML;

Or contentWindow instead of contentDocument:

document.getElementById('step1').innerHTML = document.getElementsByTagName('iframe')[0].contentWindow.document.body.innerHTML;

iframe.contentDocument is the same as iframe.contentWindow.document

HTML: Getting document from IFrame

Community
  • 1
  • 1
CoderPi
  • 12,985
  • 4
  • 34
  • 62
  • Umh... Reading the error message, it tells, that `document.getElementsByTagName('iframe')` returns an empty collection ... – Teemu Dec 05 '15 at 17:38
  • that is new.. I guess it can't find any iframe-tag. We need the HTML-Code – CoderPi Dec 05 '15 at 17:39