i want to add a javascript File or Function to vb.net application web browser.
i am using this function:
Dim mScript As HtmlElement
Dim mHead As HtmlElementCollection
mHead = Browser1.Document.GetElementsByTagName("head")
With Browser1
mScript = .Document.CreateElement("script")
mScript.SetAttribute("type", "text/javascript")
mScript.SetAttribute("src", SoftwareROOT & "\plugin.js")
.Document.Body.AppendChild(mScript)
.Document.InvokeScript("script_load")
End With
when i execute this function, it creates a new element at the bottom of page successfully.
but the function .Document.InvokeScript("script_load") is not working..
Update:
JS File is here:
function script_load(){ alert(‘Hi from Script’); }
script_load();
You need to wait for it to load, and that will take at least a little time. Instead, just run the
script_load()function directly and immediately in your JavaScript; it won’t make any difference.