简体   繁体   中英

Parsing a webpage with WebBrowser before DocumentCompleted

There is a web page (call it main) that contains several frames.

The main and all its included frames raise event DocumentCompleted .

The order of those events is: Subframe1, subframe2, subframeX.., main.

What I want is to parse the content of the main and add some handlers on several html elements on it before the user can take any action. (For example button.Click or link.Click ). Till now this is possible by waiting the DocumentCompleted and checking the event's arguments for the correct frame.

However, sometimes the included frames happen to take much time to load and the desired event is not raised within a reasonal amount of time. However the page is visible by the user despite the fact that parsing and the addition of the handlers cannot be done.

So the impatient user interacts with the page, which messes up all the work.

Is there a recommended way to parse the page sooner without waiting for DocumentCompleted (as long as the data is there of course) and keep doing it silently (that is: not show a waiting form or popup to the user)?

您可以使用“ Navigated”事件,请看这里

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