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 m
i came up on your post, while playing around with things following worked for me:
HtmlElementCollection head = webBrowser1.Document.GetElementsByTagName("head");
if (head != null)
{
HtmlElement elm = webBrowser1.Document.CreateElement("script");
elm.SetAttribute("type", "text/javascript");
elm.InnerText = System.IO.File.ReadAllText(Environment.CurrentDirectory + @"\helperscripts.js");
((HtmlElement)head[0]).AppendChild(elm);
}
, so all methods of helperscript.js can be invoked using
webBrowser1.Document.InvokeScript("methodname");
, here as a reference for the script invoke: How to inject Javascript in WebBrowser control?
greetings