I\'ve tried this:
string newScript = textBox1.Text;
HtmlElement head = browserCtrl.Document.GetElementsByTagName(\"head\")[0];
HtmlElement scriptEl = browser
The managed wrapper for the HTML document doesn't completely implement the functionality you need, so you need to dip into the MSHTML API to accomplish what you want:
1) Add a reference to MSHTML, which will probalby be called "Microsoft HTML Object Library" under COM references.
2) Add 'using mshtml;' to your namespaces.
3) Get a reference to your script element's IHTMLElement:
IHTMLElement iScriptEl = (IHTMLElement)scriptEl.DomElement;
4) Call the insertAdjacentText method, with the first parameter value of "afterBegin". All the possible values are listed here:
iScriptEl.insertAdjacentText("afterBegin", "function sayHello() { alert('hello') }");
5) Now you'll be able to see the code in the scriptEl.InnerText property.
Hth, Richard