Parameter | Description |
---|---|
iNavigationId | Navigation operation identifier |
sUrl | New URL that will be loaded |
bIsRedirected | True if this navigation is caused by a server redirect |
bIsUserInitiated | True if the navigation is caused by a user action |
bCancelnavigation (ByRef) | Set to true to cancel the navigation |
Procedure OnNavigationStarting UBigInt iNavigationId String sUrl Boolean bIsRedirected Boolean bIsUserInitiated Boolean ByRef bCancelnavigation
This message is sent when a new navigation operation is being initiated.
It provides details on the new navigation operation like the loaded URL and how the operation was triggered.
The bCancelNavigation parameter can be set to True to stop the navigation operation from proceeding.
Each navigation operation gets a unique identifier indicated by the iNavigationId parameter. The OnNavigationCompleted event also gets this same identifier.
Some navigation operations fire multiple OnNavigationStarting events whilst there is always only one OnNavigationCompleted. HTTP redirects returned by the server can cause this to happen.
The list below shows in which order navigation related events happen with some details.
1. OnNavigationStarting
WebView2 starts to navigate to the specified URL. The host application can disallow the the navigation by setting bCancelNavigation to true. On cancelling or failure it will skip directly to OnNavigationCompleted.
2. OnSourceChanged
The source changed to a new URL. This does not indicate that a network request happened.
3. OnContentLoading
WebView starts loading content for the new page.
4. OnHistoryChanged
The navigation caused the history to be updated.
5. OnNavigationCompleted
The navigation has completed and the new content has been loaded.