Load url from same domain to iframe - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame

Description

Load url from same domain to iframe

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from  w w w .  j ava 2 s  .  co m

var url="http://same domain/test";
var iframe=document.createElement("iframe");
iframe.onload=function()
{
    console.log(iframe.contentWindow.document.body.innerHTML);
}
iframe.src=url;
iframe.style.display="none";
document.body.appendChild(iframe);

    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials