I just started using Visual Studio 2010 C# IDE today.
I'm trying to inject javascript to WebBrowser component and followed the answer from stackoverflow:
How to inject Javascript in WebBrowser control?
HtmlElement txtBox = webBrowser1.Document.GetElementById("UserEmailShortcut");
//js
HtmlElement scriptOne = webBrowser1.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptOne.DomElement;
element.text = "function sayHello() { alert('hello') }";
txtBox.AppendChild(scriptOne);
webBrowser1.Document.InvokeScript("sayHello");
Now there is red wavy line under IHTMLScriptElement saying:
Error 1 The type or namespace name 'IHTMLScriptElement'
could not be found (are you missing a using directive or an assembly reference?)
C:\Users\m-tak\documents\visual studio
2010\Projects\winformWithWebBrowserTest\winformWithWebBrowserTest\Form1.cs
25 13 winformWithWebBrowserTest
I've looked documentation http://msdn.microsoft.com/en-us/library/aa768904(v=VS.85).aspx
but I can't figure why. Isn't this already included and just need to include like "using IHTMLScriptElement
" (which didn't work..)