I’m doing javascript injection, below is my code.
HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = webBrowser1.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
element.text = "function sayHello() { debugger; alert('Helloooo');" + " var resume=webBrowser1.Document.GetElementByTagName('resID');" +
" var i; for (i=0;i<resume.length;i++){if (resume[i].checked){alert(\"hi....\");} } }";
head.AppendChild(scriptEl);
System.Diagnostics.Debug.Print("html: {0}",head.InnerHtml);
webBrowser1.Document.InvokeScript("sayHello");`
My check box name is resID. The statement after alert in sayHello function is not executing. The result of this code is , its giving alert as Hello and its stopping execute. Is there any mistake in my code while accessing check box value. I
change the line.
to