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

The key of the data to read.

In This Topic
    ReadLocalStorage Method
    In This Topic
    Description

    Read dictionary-based data from local storage.

    Syntax
    Visual Basic
    Public Function ReadLocalStorage( _
       ByVal Name As String _
    ) As String
    Parameters
    Name

    The key of the data to read.

    Return Type

    The value of the data to read.

    Remarks

    For local storage to work you must handle the OnCreate event and set the following settings:

    • Settings.user_data_path = App.Path + "\UserData"
    • Settings.persist_user_preferences = 1
    • Settings.local_storage = True 
    Example
    Option Explicit
    
    Private Sub Form_Resize()
        On Error Resume Next
        WebKitX.Move 0, 0, ScaleWidth, ScaleHeight
        Err.Clear
    End Sub
    
    Private Sub WebKitX_OnBrowserReady()
        
        ' For local storage to work, you need a URL
        WebKitX.Open App.Path + "\test.html"
    
    End Sub
    
    Private Sub WebKitX_OnCreate(ByVal Settings As WebKitXCEF3Lib.ISettings, CommandLineSwitches As String)
        
        ' For local storage to work, you need the following settings
        Settings.cache_path = App.Path + "\Cache"
        Settings.user_data_path = App.Path + "\UserData"
        Settings.persist_user_preferences = 1
        Settings.local_storage = True
        
    End Sub
    
    Private Sub WebKitX_OnLoadEnd()
        
        ' The eval() way
        WebKitX.Eval "window.localStorage.setItem('lastname', 'Smith');"
        MsgBox WebKitX.Eval("localStorage.lastname")
        
        ' The API way
        WebKitX.WriteLocalStorage "This is my variable !@$", "This is its value !!" + vbCrLf + "It has two lines!"
        MsgBox WebKitX.ReadLocalStorage("This is my variable !@$")
        
    End Sub
    See Also