title: loading remote page into DOM with javascript
body: <p>I am trying to write a web widget which will allow users to display customized information (from my website) in their own web page. The mechanism I want to use (for creating the web widget) is javascript.</p>
  
  <p>So basically, I want to be able to write some javascript code like this (this is what the end user copies into their HTML page, to get my widget displayed in their page)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  /* javascript here to fetch page from remote url and insert into DOM */
  &lt;/script&gt;
  </code></pre>
  
  <p>I have two questions:</p>
  
  <ol>
  <li><p>how do I write a javascript code to fetch the page from the remote url?
  Ideally this will be PLAIN javascript (i.e. not using  jQuery etc - since I dont want to force the user to get third party scripts jQuery which may conflict with other scripts on their page etc)</p></li>
  <li><p>The page I am fetching contains inline javascript, which gets executed in an body.onLoad event, as well as other functions which are used in response to user actions - my questions are: </p></li>
  </ol>
  
  <p>i). will the body.onLoad event be triggered for the retrieved document?. 
  ii). If the retrieved page is dumped directly into the DOM, then the document will contain two <code>&lt;body&gt;</code> sections, which is no longer valid (X)HTML - however, I need the body.onLoad event to be triggered for the page to be setup correctly, and I also need the other functions in the retrieved page, for the retrieved page to be able to respond to the user interaction.</p>
  
  <p>Any suggestions/tips on how I can solve these problems?</p>