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

The JavaScript function name to call.

An OLE/COM Variant passed to the JavaScript function.

In This Topic
    CallByNameAsync Method
    In This Topic

    Calls a JavaScript function asynchronously of the global scope, no result is returned.

    Visual Basic
    Public Sub CallByNameAsync( _
       ByVal Name As String, _
       ByVal Arguments As Variant _

    The JavaScript function name to call.


    An OLE/COM Variant passed to the JavaScript function.


    The simplest way to call a JavaScript function in WebKitX is WebKitX.CallByName(Name, Variant) method. You can pass to JavaScript function arbitrary arguments using an OLE/COM Variant.

    Execution of CallByName is IPC-synchronous and this method is an elegant alternative to Eval code as you can pass back-and-forth your variables without stringifying them.

    OLE/COM Variants to V8 Values Conversion

    WebKitX has a powerful OLE/COM Variant to Google V8 Value bi-directional converter that works both for Scalar and Array values, including nested array values (arrays of arrays of variants). This conversion mechanism is available to any WebKitX method transmitting and/or returning an OLE/COM Variant, such as CallByNameJSCallBack and DispatchEvent.

    WebKitX can serialize variant scalars VT_BSTR, VT_UINT, VT_INT, VT_NULL, VT_BOOL, VT_R4, VT_R8, VT_CY, VT_DATE as well as variant safearray of variants VT_ARRAY | VT_VARIANT and even typed arrays VT_ARRAY | VT_BSTR, VT_ARRAY | VT_UINT, VT_ARRAY | VT_INT, VT_ARRAY | VT_BOOL, VT_ARRAY | VT_R4, VT_ARRAY | VT_R8, VT_ARRAY | VT_CY, VT_ARRAY | VT_DATE to Google V8 JavaScript value objects.

    • Currently serialization of VT_DISPATCH is not supported and therefore you cannot pass OLE/COM Objects to JavaScript.
    • On the OLE/COM side, to pass multiple arguments to a JavaScript callback function you need to wrap them in a Variant Array of Variants.
    • On the JavaScript side, you can return V8 Scalar or V8 Array values to OLE/COM side, including nested V8 Arrays.

    WebKitX can serialize V8 scalar Boolean, Number, String, Null, Date values and Array of [Boolean or Number or String or Null or Date or Array] V8 values.

    Google V8 Arrays are always returned as Variant Arrays of Variants. On the receiving OLE/COM side the scalars are converted to a Variant of equivalent scalar type and Arrays are converted into a Variant Array of Variants.

    Private Sub mnuTestCallByName_Click()
        On Error Resume Next
        Dim s As String    
        s = InputBox("Function to call", , "foo")
        If s = "" Then Exit Sub
        WebKitX1.CallByNameAsync s, Array("My Data", 10, 3.14, Date + Time)    
    End Sub
    See Also