webgary
Posts: 1
Joined: 2012-03-14
|
Loading JavaScript functions OnDocumentComplete
I am very new to C#, IE BHOs and Add-in Express for Internet Explorer.
I am trying to build an ADX IE add-on in C# that loads a Javascript function set into the head of the document after the browser loads a page.
By research I have come up with the code:
public void OnDocumentComplete(object pDisp, ref object URL)
{
HTMLDocument document = (HTMLDocument)webBrowser.Document;
IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)document.all.tags("head")).item(null, 0);
IHTMLScriptElement headScript = (IHTMLScriptElement)document.createElement("script");
headScript.text = "alert('Hi!')";
((HTMLHeadElement)head).appendChild((IHTMLDOMNode)headScript);
}
Is this code even close for what I am trying to do?
What part of this code will need to be modified?
What References would I need to add to make this work?
If I am going in a completely wrong direction please point me in a correct direction, with code samples if possible.
Thank you very much,
Gary A Johnson |
|
Eugene Astafiev
Guest
|
|