title: How to inject Javascript in WebBrowser control?
body: <p>I've tried this:</p>
  
  <pre><code>string newScript = textBox1.Text;
  HtmlElement head = browserCtrl.Document.GetElementsByTagName("head")[0];
  HtmlElement scriptEl = browserCtrl.Document.CreateElement("script");
  lblStatus.Text = scriptEl.GetType().ToString();
  scriptEl.SetAttribute("type", "text/javascript");
  head.AppendChild(scriptEl);
  scriptEl.InnerHtml = "function sayHello() { alert('hello') }";
  </code></pre>
  
  <p>scriptEl.InnerHtml and scriptEl.InnerText both give errors:</p>
  
  <pre><code>System.NotSupportedException: Property is not supported on this type of HtmlElement.
     at System.Windows.Forms.HtmlElement.set_InnerHtml(String value)
     at SForceApp.Form1.button1_Click(Object sender, EventArgs e) in d:\jsight\installs\SForceApp\SForceApp\Form1.cs:line 31
     at System.Windows.Forms.Control.OnClick(EventArgs e)
     at System.Windows.Forms.Button.OnClick(EventArgs e)
     at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
     at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
     at System.Windows.Forms.Control.WndProc(Message&amp; m)
     at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
     at System.Windows.Forms.Button.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  </code></pre>
  
  <p>Is there an easy way to inject a script into the dom?</p>