Skip to content Skip to sidebar Skip to footer

DocumentElement.innerHTML Not Showing The Iframe Body

i have got a page that has one iframe in it. i am making the iframe via javascript. later i need to save that page and reopen it with the exact contents. like e.g if the user wrote

Solution 1:

Based on this post, here a solution:

UPDATE

function showIF()
{
  var f= document.getElementById('myIframe');
  var d= f.contentDocument? f.contentDocument : f.contentWindow.document;
  var customArea = document.getElementById('custom-area');
  //read the content of iframe
  var iframeContent = d.body.innerHTML;
  //delete the iframe himself
  f.parentNode.removeChild(f);
  //Append the html to parent div
  customArea.innerHTML += iframeContent;
  //console.log(d.body.innerHTML);
}

At least it works with my Chrome browser (Version 11.0.696.60)


Post a Comment for "DocumentElement.innerHTML Not Showing The Iframe Body"