How to get the body's content of an iframe in JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

To get the body’content, you can get the src attribute or try the following code snippet −

<iframe id = "myId" name = " myId ">...</iframe>

<script>
   var myDoc;

   if (window.frames && window.frames. myId && (myDoc = window.frames. myId.document)) {
     var iframeBody = myDoc.body;
     var content = iframeBody.innerHTML;
   }
</script>
raja
Published on 01-Mar-2018 10:43:27
Advertisements