如何使用Document.GetElementById(“NAME”)。单击? [英] How do I use Document.GetElementById("NAME").Click?

查看:177
本文介绍了如何使用Document.GetElementById(“NAME”)。单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

我试着只是正常地做,但它一直告诉我它需要在a =或+ =的另一边。如何解决这个问题?

I tried just doing it normally, but it kept telling me it needed to be on the other side of a = or +=. How do I fix this?

我使用的代码是:
browser.Document.GetElementById(ap_h)。

The code I'm using is: browser.Document.GetElementById("ap_h").Click;

推荐答案

您要查找的代码片段是:

The piece of code you are looking for is:

Invoke DOM元素中的方法

// The WebBrowser control
System.Windows.Forms.WebBrowser webBrowser;

// Perform a click on an element
HtmlDocument document = webBrowser.Document;
document.GetElementById("id_of_element").InvokeMember("Click");

上面的代码为您在WebBrowser控件中执行点击。

The code above performs the click in the WebBrowser Control for you.

分配事件处理程序

如果要分配事件处理程序:

If you want to assign an event handler:

document.GetElementById("id_of_element").Click 
                             += new HtmlElementEventHandler(el_Click);

其中:

void el_Click(object sender, HtmlElementEventArgs e)
{
     // Do something
}

这篇关于如何使用Document.GetElementById(“NAME”)。单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆