title: WebBrowser not running javascript
body: <p>I'm utilizing a <code>System.Windows.Forms.WebBrowser</code> (used in a separate .dll file)  from my <code>WPF</code> application in order to print some <code>HTML</code> content in the background.<br>
  My problem is that the HTML elemnts are not being affected by the <code>javascript</code> in the page.<br>
  I know that there are no errors in the page because that if I copy its content after the <code>DocumentCompleted</code> event and paste it into a plain HTML file the script works.<br>
  <strong>My HTML template:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en" xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;script&gt;
      function loaded() {
          document.getElementById("content").innerHTML = "after javascript";
      }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="loaded()"&gt;
      &lt;h1 id="content"&gt;before javascript&lt;/h1&gt; &lt;!--&lt;= This value does not change--&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>I use this HTML as follows:</strong></p>
  
  <pre><code>private void PrintTest()
  {
      string curDir = Directory.GetCurrentDirectory();
      string fullPath = Path.Combine(curDir, "PrintDocs\\HTMLPage1.html");
  
      string html = File.ReadAllText(fullPath);
  
      HtmlPrint.Print(html);
  }
  
  public static class HtmlPrint
  {
      public static void Print(string html, string documentTitle = "")
      {
          var wb = new System.Windows.Forms.WebBrowser { DocumentText = html };
          wb.DocumentCompleted += wb_DocumentCompleted;
      }
  
      private static void wb_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
      {
          var wb = ((System.Windows.Forms.WebBrowser)sender);
  
          wb.Print();
          wb.Dispose();
      }
  }
  </code></pre>
  
  <p>What am I missing here?</p>