mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / Open Method

The URL to load.

Open Method
Description

Opens a URL for loading.

Syntax
Visual Basic
Public Sub Open( _
   ByVal url As String _
) 
Parameters
url

The URL to load.

Remarks

You are advised to make use of the protocol (http, https, file) part of the URL. 

WebKitX provides several Events during its initialization, creation of the browser and loading of a URL. First you need to set the licensing information by handling the early Form Loading or Creation event. Then you can control CEF Browser creation by handling the OnCreate event. Once the browser is ready it will emit the the OnBrowserReady event where you can enable JavaScript or HTML5 editing parameters. In OnBrowserReady you should also load the HTML5 markup or navigate to the URL you want to load.

Image Title

Image Title

During loading WebKitX will fire several loading events such as OnLoadStart and OnLoadEnd. If you are loading HTML with frames (IFRAMEs) then some events will fire multiple times, such as OnPageLoadStart and OnPageLoadEnd. When the main frame is loaded WebKitX will fire OnLoadEnd and when all frames have loaded WebKitX will fire the OnPageComplete event.

When you receive the OnLoadEnd and OnPageLoadEnd events, it means that network-wise the contents have downloaded but HTML-wise the contents might not be fully parsed yet. In HTML terms this means that document.readyState value might not not set to complete. Pages in window or sub frames might be in interactive state and resources might be loading in the background. The only event that guarantees that the main window frame and all sub-frames have document.readyState = complete is OnPageComplete.

Internally, WebKitX uses an asynchronous task that checks the document.readyState for all frames; if this check result is "complete" with a count equal to browser frames, then the event is fired. If some frames have loaded while other frames have failed, the event will not fire. The check takes place on a fresh HTML DOM snapshot obtained every time at the moment of the check, and examines the current number of frames. The frames must remain unchanged for 3 seconds before the event is fired; this way, any dynamic loading or unloading of frames is taken into account.

Please note that some frameworks such as Angular and React dynamically load portions of the page. WebKitX events will keep firing while dynamic content is downloaded. You need to examine the behavior of the control in relation with the web site you want to display and adjust your event handling accordingly

Example
Private Sub WebKitX1_OnBrowserReady()
    
    On Error Resume Next
    
    ' Restore focus to WebKitX after a command is executed (form a menu or context menu)
    WebKitX1.ExecCommandSetFocus = True
    
    ' Enable mobileFX formatting vs. CEF3 formatting (Recommended)
    WebKitX1.FormatUsingInternalSelectionAPI = True
    
    ' Allow JavaScript download (sometimes scripts such as parallax mess with HTML5 styles)
    WebKitX1.DownloadScripts = False
    mnuDownloadScripts.Checked = False
    
    ' Initial HTML to show (optional)
    
    If LoadFile <> "" Then
        WebKitX1.Open LoadFile
        LoadFile = ""
    Else
        WebKitX1.HTML = "<html><body></body></html>"
    End If
    
    'WebKitX1.Open "file:///my_path/index.html"
    
End Sub
See Also