sorry, my poor English,my question is as following:
Calling JavaScript in a WebBrowser control from C# in ordinary way: JavaScript
function showMe()
{ ... }
C#
webBrowser1.Document.InvokeScript("showMe");
that is ok!
but how to call in such situation:
html:
<a href="javascript:void(0);" onclick="App.followcancel('1880161672',this,'0','A','B');return false;">hello</a>
c#:
webBrowser1.Document.InvokeScript(????????)
I don't know how to 开发者_如何学编程write the correct paremeter to achieve the onclick's javascript
anyone help me,thanks a lot
Something like this (if you set id of the link to "mylink"):
HtmlElement el = webBrowser1.Document.All["mylink"];
object obj = el.DomElement;
System.Reflection.MethodInfo mi = obj.GetType().GetMethod("onclick");
mi.Invoke(obj, new object[0]);
Following the example you've given:
webBrowser1.Document.InvokeScript("App.followcancel('1880161672',this,'0','A','B')");
Edit: This example is broken.
You would need to replace 'this' with document.getElementById('mylink')
(assuming an id
attribute is set with the value mylink
) or use the approach given by HABJAN.
精彩评论