Fired before a Frame loads a new URL. The event is classified as synchronous and for performance reasons is disabled by default. Read remarks section below to enable it.
The HTTP Request identifier.
The Browser identifier.
The Frame identifier.
The Frame name (if any).
Indicates if the navigation is an HTTP redirect.
HTTP Method (POST, GET, etc.)
Get the referrer URL.
The current URL of the Frame.
By setting this argument you can alter the navigation URL programmatically.
By setting this argument to True you can cancel the navigation.
Fired before a Frame loads a new URL. The event is classified as synchronous and for performance reasons is disabled by default. Read remarks section below to enable it.
Visual Basic |
---|
Public Event OnBeforeNavigate( _ ByVal Id As Long, _ ByVal BrowserID As Long, _ ByVal FrameID As Long, _ ByVal FrameName As String, _ ByVal IsRedirect As Boolean, _ ByVal ResourceType As NAV_RESOURCE_TYPE, _ ByVal TransitionType As NAV_TRANSITION_TYPE, _ ByVal Method As String, _ ByVal ReferrerURL As String, _ ByVal CurrentURL As String, _ ByRef NewURL As String, _ ByRef Cancel As Boolean _ ) |
The HTTP Request identifier.
The Browser identifier.
The Frame identifier.
The Frame name (if any).
Indicates if the navigation is an HTTP redirect.
Value | Description |
---|---|
RT_CSP_REPORT | A report of Content Security Policy violations. |
RT_FAVICON | Favicon. |
RT_FONT_RESOURCE | Font. |
RT_IMAGE | Image (jpg/gif/png/etc). |
RT_MAIN_FRAME | Top level page. |
RT_MEDIA | Media resource. |
RT_OBJECT | Object (or embed) tag for a plugin, or a resource that a plugin requested. |
RT_PING | A request for a <ping> |
RT_PLUGIN_RESOURCE | A resource that a plugin requested. |
RT_PREFETCH | Explicitly requested prefetch. |
RT_SCRIPT | External script. |
RT_SERVICE_WORKER | Main resource of a service worker. |
RT_SHARED_WORKER | Main resource of a shared worker. |
RT_STYLESHEET | CSS stylesheet. |
RT_SUB_FRAME | Frame or iframe. |
RT_SUB_RESOURCE | Some other sub resource. This is the default type if the actual type is unknown. |
RT_WORKER | Main resource of a dedicated worker. |
RT_XHR | XMLHttpRequest. |
Value | Description |
---|---|
TT_AUTO_SUBFRAME | Source is a subframe navigation. This is any content that is automatically loaded in a non-toplevel frame. For example, if a page consists of several frames containing ads, those ad URLs will have this transition type. The user may not even realize the content in these pages is a separate frame, so may not care about the URL. |
TT_BLOCKED_FLAG | Attempted to visit a URL but was blocked. |
TT_CHAIN_END_FLAG | The last transition in a redirect chain. |
TT_CHAIN_START_FLAG | The beginning of a navigation chain. |
TT_CLIENT_REDIRECT_FLAG | Redirects caused by JavaScript or a meta refresh tag on the page. |
TT_DIRECT_LOAD_FLAG | |
TT_EXPLICIT | Source is some other "explicit" navigation action such as creating a new browser or using the LoadURL function. This is also the default value for navigations where the actual type is unknown. |
TT_FORM_SUBMIT | Source is a form submission by the user. NOTE: In some situations submitting a form does not result in this transition type. This can happen if the form uses a script to submit the contents. |
TT_FORWARD_BACK_FLAG | Used the Forward or Back function to navigate among browsing history. |
TT_IS_REDIRECT_MASK | Used to test whether a transition involves a redirect. |
TT_LINK | Source is a link click or the JavaScript window.open function. This is also the default value for requests like sub-resource loads that are not navigations. |
TT_MANUAL_SUBFRAME | Source is a subframe navigation explicitly requested by the user that will generate new navigation entries in the back/forward list. These are probably more important than frames that were automatically loaded in the background because the user probably cares about the fact that this link was loaded. |
TT_QUALIFIER_MASK | General mask defining the bits used for the qualifiers. |
TT_RELOAD | Source is a "reload" of the page via the Reload function or by re-visiting the same URL. NOTE: This is distinct from the concept of whether particular load uses "reload semantics" (i.e. bypasses cached data). |
TT_SERVER_REDIRECT_FLAG | Redirects caused by JavaScript or a meta refresh tag on the page. |
TT_SOURCE_MASK | General mask defining the bits used for the source values. |
HTTP Method (POST, GET, etc.)
Get the referrer URL.
The current URL of the Frame.
By setting this argument you can alter the navigation URL programmatically.
By setting this argument to True you can cancel the navigation.
The event is fired on the UI thread before browser navigation of the main frame.
For performance reasons the event is disabled by default. Intercepting navigation in CEF requires the browser thread to be blocked until the OLE / COM event is handled, which subsequently requires switching to synchronous events model between the ActiveX and Chromium Embedded Framework sub-processes.
Set Cancel to true to cancel the navigation or false to allow the navigation to proceed. You can also stop a URL navigation that has already started with StopLoading Method.
You can set a different URL to navigate to by setting the NewURL argument.
Option Explicit Public URL As String Private Sub Form_Load() URL = "https://www.webkitx.com/" End Sub Private Sub Form_Resize() On Error Resume Next WebKitX1.Move 0, 0, ScaleWidth, ScaleHeight Err.Clear End Sub Private Sub WebKitX1_OnCreate(ByVal Settings As WebKitXCEF3Lib.ISettings, CommandLineSwitches As String) Settings.asynchronous_com_events = False Settings.allow_cancel_on_before_navigate = True Settings.disable_on_before_navigate_event = False End Sub Private Sub WebKitX1_OnBrowserReady() WebKitX1.Open URL End Sub Private Sub WebKitX1_OnBeforeNavigate(ByVal ID As Long, ByVal BrowserID As Long, ByVal FrameID As Long, ByVal FrameName As String, ByVal IsRedirect As Boolean, ByVal ResourceType As WebKitXCEF3Lib.NAV_RESOURCE_TYPE, ByVal TransitionType As WebKitXCEF3Lib.NAV_TRANSITION_TYPE, ByVal Method As String, ByVal ReferrerURL As String, ByVal CurrentURL As String, NewURL As String, Cancel As Boolean) If NewURL = URL Then ' Ask the user what to do with the URL Dialog.Label1 = "Load URL?" + vbCrLf + NewURL Dialog.Show vbModal Cancel = Not Dialog.Result End If Unload Dialog End Sub