例如:
Webbrowser1.Document.GetElementById("btn").InvokeMember("Click");
click之后发现Webbrowser1的状态为complete没变,isbusy也为false没变,使用thread.sleep和timer则webbrowser浏览器就不动了,使用状态判断和时间延迟的方式都不行
那么请问如何判断click触发的事件执行完毕阿
Webbrowser1.Document.GetElementById("btn").InvokeMember("Click");
click之后发现Webbrowser1的状态为complete没变,isbusy也为false没变,使用thread.sleep和timer则webbrowser浏览器就不动了,使用状态判断和时间延迟的方式都不行
那么请问如何判断click触发的事件执行完毕阿
this.webBrowser1.Document.InvokeScript("msgalert", new string[] { "C# 访问JS代码" });
这样应该可以访问到 测试过了 html网页上的 <script type="text/javascript">
function msgalert(msg) {
alert(msg);
}
</script> 如果报com可访问性错误的话 加上[System.Runtime.InteropServices.ComVisibleAttribute(true)] 这句话就可以了 测试过了
CSharpMethodForJavaScript cs = new CSharpMethodForJavaScript(this);
webBrowser1.ObjectForScripting = cs;[System.Runtime.InteropServices.ComVisibleAttribute(true)]//将该类设置为com可访问
public class CSharpMethodForJavaScript
{
public void clickComplete(){
// click完成