This seems really dumb. I've tried a bunch of different ways and it's just not working. I have a WinForms app with a WebBrowser control. If I try with a raw html file on my desktop using the same src string, the src I put together works fine. But plugging the same stuff into the WebBrowser control won't work.
Here's 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);
}
The WebBrowser doesn't get the script. However, if I change "mySource" to an external resource (via http://), it works fine!
Help!