It seems really stupid. I tried a bunch of different ways and it just doesn't work. I have a WinForms application with a WebBrowser control. If I try with a raw html file on my desktop using the same src line, then the src that I put together works fine. But including the same element in a WebBrowser control will not work.
Here is my code:
HtmlElementCollection head = this.wbPreview.Document.GetElementsByTagName( "head" ); if (head != null) { HtmlElement elm = this.webBrowserControl.Document.CreateElement("script"); string mySource = Environment.CurrentDirectory + @"\MyScriptFile.js"; elm.SetAttribute("src", mySource); elm.SetAttribute("type", "text/javascript"); ((HtmlElement)head[0]).AppendChild(elm); }
WebBrowser does not receive script. However, if I change mySource to an external resource (via http: //), it works great!
Help!
javascript html c # webbrowser-control
IAmAN00B Oct 27 '10 at 2:40 2010-10-27 02:40
source share