简体   繁体   中英

How do i simulate a click event in a webbrowser control? .NET

So there is a button call next (page). Its href link is site/blah/#. So i know its really running javascript code. After i finish parsing the first page i would like to parse the next page. How do i simulate a mouse click there so i can continue loading and parsing pages?

i am using C# .NET

childElement.RaiseEvent( “点击”);

If you know the id of the tag you can use below given code

WebBrowser1.Document.GetElementById("submit").InvokeMember("click")

if you dont know the id you can follow this code

foreach (System.Windows.Forms.HtmlElement html in WebBrowser1.Document.GetElementsByTagName("a")) {
    if (html.InnerText == "YOUR TEXT") {
         html.InvokeMember("click");
    }
}

Contact if you have any doubt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM