Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
995 views
in Technique[技术] by (71.8m points)

c# - WinForms Microsoft.Web.WebView2 Navigate, Page Fully Loaded

I am trying execute a method after the action this.webViewBrowser.CoreWebView2.Navigate(url).

As of yet are failing as the page is not fully load and dynamic scripts executed.

The Microsoft.Web.WebView2 Nuget package is v1.0.781-prerelease.

Kind regards,

Neil

question from:https://stackoverflow.com/questions/66052640/winforms-microsoft-web-webview2-navigate-page-fully-loaded

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

as the page is not fully load and dynamic scripts executed. → It basically means you need to wait a bit. There is not such an event to detect when those dynamic content loading scripts are finished. They may work continuously to refresh some information in page.

As a general answer, for those who are looking for a load event, There are two events which help you detect load event:

  • WebView2.NavigationCompleted → is raised when the WebView has completely loaded (body.onload has been raised) or loading stopped with error.
  • WebView2.CoreWebView2.DOMContentLoaded → is raised when the initial html document has been parsed. This aligns with the the document's DOMContentLoaded event in html. (This one is available starting from 1.0.705.50.)

But just keep in mind, if you have a page which performs some ajax requests (when document is ready), I assume it's obvious that above events will raise before you see all the content. In these cases you just need to wait a bit after the events raised.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...