Html code as IFRAME source rather than a URL - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame

Description

Html code as IFRAME source rather than a URL

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 a va 2s. c o  m
    var iframe = document.getElementById('foo'),
    iframedoc = iframe.contentDocument || iframe.contentWindow.document;
    iframedoc.body.innerHTML = 'Hello world';

}

      </script> 
   </head> 
   <body> 
      <iframe id="foo"></iframe>  
   </body>
</html>

Related Tutorials