title: How do I build an iframe with the same domain as the page in Safari/WebKit
body: <p><strong>The scene</strong>: I'm writing an embeddable widget.  It takes the form of a <code>&lt;script&gt;</code> tag, which builds an iframe containing everything it needs to display.  The iframe has no <code>src</code>, and the script writes to it with <code>theIframe.contentWindow.document.write()</code>.  This keeps the widget contained, and keeps element ids and script from conflicting with the page on which the widget is embedded.</p>
  
  <p><strong>The trick</strong>: The widget has to be able to change its size.  To do this, it sets its containing iframe's <code>style.height</code>.  This requires access to the outer page's DOM.  In <strong>Firefox</strong> and <strong>IE</strong>, this is allowed, because the iframe's document and the outer document are considered to share an origin.</p>
  
  <p><strong>The twist</strong>: In <strong>Safari</strong>, however, the two documents are considered <em>not</em> to share an origin.  The inner document is considered to be at <code>about:blank</code>, while the outer document is clearly using a different protocol and "domain" (if <code>blank</code> can be considered the domain).</p>
  
  <p><strong>The question</strong>: How can I build an iframe programmatically whose document Safari/WebKit will consider to have the same origin as the document of the window creating it?</p>
  
  <hr>
  
  <p><strong>Edit</strong>: After further experimentation, I can't find a way to programmatically create an iframe whose location is not <code>about:blank</code> regardless of whether I change its contents.</p>
  
  <p>If I create the frame with <code>document.createElement()</code>, give it a <code>src</code> which points to a real HTML resource on the same origin called "foo.html", and <code>document.body.appendChild()</code> it, Safari's console shows the element as expected in the DOM, but the contents of the page do not appear, and the document is listed in the sidebar as "about:blank".</p>
  
  <p>If I include the HTML for the iframe directly in the page, the contents of <code>foo.html</code> appear, and "foo.html" appears in the sidebar.</p>
  
  <p>If I insert the HTML using <code>document.write()</code>, I get the same result as with <code>document.body.appendChild()</code>.</p>
  
  <p>Both programmatic versions work in Firefox.</p>