mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / OnComPostMessage Event

An OLE/COM Variant returned from the JavaScript context by calling window.postComMessage function.

When you call window.postComMessage function you can pass arbitrary scalar JavaScript values which are converted to Strings (BSTR).

postComMessage
Copy Code
window.postComMessage(5);
window.postComMessage(3.14);
window.postComMessage("Hello World!");
window.postComMessage(new Date());
window.postComMessage(true);
window.postComMessage(5, 3.14, "Hello World", new Date(), true);
In This Topic
    OnComPostMessage Event
    In This Topic
    Description

    Fired when you execute in JavaScript the window.postComMessage(value) function in order to pass values from JavaScript to your application.

    Syntax
    Visual Basic
    Public Event OnComPostMessage( _
       ByRef Params As Variant _
    )
    Parameters
    Params

    An OLE/COM Variant returned from the JavaScript context by calling window.postComMessage function.

    When you call window.postComMessage function you can pass arbitrary scalar JavaScript values which are converted to Strings (BSTR).

    • If you pass a single argument to window.postComMessage, the ActiveX calls InitVariantFromString and Params is an OLE/COM Variant of VT_BSTR.
    • If you pass multiple arguments to window.postComMessage, the ActiveX calls InitVariantFromStringArray and Params is an OLE/COM Variant of VT_ARRAY | BT_BSTR.
    postComMessage
    Copy Code
    window.postComMessage(5);
    window.postComMessage(3.14);
    window.postComMessage("Hello World!");
    window.postComMessage(new Date());
    window.postComMessage(true);
    window.postComMessage(5, 3.14, "Hello World", new Date(), true);
    Remarks

    WebKitX implements a bi-directional mechanism for sending data from your application to JavaScript and from JavaScript to your application.

    To sent data from your application to JavaScript you can use:

    To send data from JavaScript to your application you can use:

    • window.postComMessage
    Example
    <html>
    <head>
    
    <script>	
    	function notify(param)
    	{
    		window.postComMessage(param);
    	}
    </script>
    
    </head>
    <body>
    	<br><br><button onclick="notify('Hello from WebKitX')">Post COM Message with String</button>
    	<br><br><button onclick="notify(5)">Post COM Message with Integer</button>
    	<br><br><button onclick="notify(3.1415)">Post COM Message with Double</button>
    	<br><br><button onclick="notify(new Date())">Post COM Message with Date</button>
    	<br><br><button onclick="notify(true)">Post COM Message with Boolean</button>
    </body>
    </html>
    Private Sub WebKitX1_OnComPostMessage(Params As Variant)
        On Error Resume Next
        ' Message originated from window.postComMessage() in JavaScript
        AddLog "OnComPostMessage: " & Params
    End Sub
    private void WebKitXCEF31_OnComPostMessage(object sender, AxWebKitXCEF3Lib._DWebKitXCEF3Events_OnComPostMessageEvent e)
    {
        AddLog("OnComPostMessage: " + e.@params);
    }
    See Also