DOMContentLoaded Event  
 

The DOMContentLoaded event occurs when the runtime has finished parsing the HTML document.

Syntax

Sub object_DOMContentLoaded( [Index As Integer] )

Remarks

The DOMContentLoaded event occurs when the WebView2 runtime has finished parsing the HTML document and constructing its Document Object Model (DOM). At this point, the document's structure is available, but external resources such as images, stylesheets, and other content may still be loading. The event does not indicate that the entire page has finished loading.

This event is useful when an application needs to interact with the document as soon as its DOM becomes available, without waiting for all page resources to finish loading. For example, an application might use this event to execute JavaScript that examines or modifies document elements, retrieves information from the page, or initializes application-specific functionality.

The DOMContentLoaded event is distinct from the NavigationCompleted event. The former indicates that the document has been parsed and its DOM is ready, while the latter indicates that a navigation operation has completed, either successfully or unsuccessfully. Applications should not assume that either event guarantees that all external resources have finished loading or that JavaScript running within the page has completed its work.

Applications should be aware that pages which dynamically generate content using JavaScript may continue modifying the DOM after this event occurs.

See Also