• Home
  • Javascript iFrame

    From https://www.dyn-web.com/tutorials/iframes/

    <style>
    iframe#ifrm {
        width: 50%;
        margin: 0 25%;
        height: 150px;
        border: 1px solid #ccc;
        margin-top: .8em;
    }
    </style>
    
    <div id="framer"></div>
    
    <script>
    var ifrm = document.createElement('iframe');
    ifrm.setAttribute('id', 'ifrm'); // assign an id
    
    // document.body.appendChild(ifrm); // to place at end of document
    
    // to place before another page element
    var el = document.getElementById('framer');
    el.parentNode.insertBefore(ifrm, el);
    
    // assign url
    ifrm.setAttribute('src', 'https://denvergeeks.com');
    </script>

    Page Contents