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

The key of the data to write.

The value of the data to write.

In This Topic
    WriteLocalStorage Method
    In This Topic
    Description

    Write dictionary-based data to local storage.

    Syntax
    Visual Basic
    Public Sub WriteLocalStorage( _
       ByVal Name As String, _
       ByVal Value As String _
    ) 
    Parameters
    Name

    The key of the data to write.

    Value

    The value of the data to write.

    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