title: Setting the base tag of a dynamically created iframe
body: <p>I'm trying to dynamically create an iframe and set it's base tag before it is created.</p>
  
  <pre><code>ifrm = document.createElement("IFRAME"); 
  ifrm.setAttribute("src", "test.html"); 
  ifrm.style.width = 400+"px"; 
  ifrm.style.height = 100+"px"; 
  
  //before creating it, can we set he base tag?
  //I.E. &lt;base href="http://example.com/MyFolder/" /&gt;
  var bt = ifrm.contentDocument.createElement("base");
  bt.setAttribute("href", "http://www.example.com/Folder/");
  ifrm.contentDocument.getElementsByTagName("head")[0].appendChild(bt);
  
  document.body.appendChild(ifrm);
  </code></pre>
  
  <p>I know i can set the base tag in the iframes src file itself. But I need to set it here.
  Thanks.</p>