PostStringWebMessage

Description

Sends the web message in a simple string (rather than a JSON string) to the top-level document in WebBrowser asynchronously.

Applies to

WebBrowser control

Syntax

controlname.PostStringWebMessage(sring webmessage)

Argument

Description

controlname

The name of the WebBrowser control.

webmessage

The message (in simple string format) to be sent to the top-level document, for example:

"{'a': 'b'}"
"1.2"
"example"

Return value

Integer.

Returns 1 if the function succeeds and a negative value if an error occurs. If any argument's value is null, the method returns null.

Usage

In the top-level document of WebBrowser, the web message can be subscribed or unsubscribed through the following JavaScript:

window.chrome.webview.addEventListener('message', handler)
window.chrome.webview.removeEventListener('message', handler)

This behaves in exactly the same manner as PostJsonWebMessage, but the data property of the event arg of the message is a string with the same value sent by this function PostStringWebMessage. Use this instead of PostJsonWebMessage if you want to communicate using simple strings rather than JSON objects.

Examples

This example sends the specified string webMessage to the top-level document.

//window.chrome.webview.addEventListener('message', arg => {
//   window.chrome.webview.postMessage(JSON.stringify(arg.data));
//        });
Integer li_return

li_return = wb_1.PostStringWebMessage("testStr")

See also

OpenDefaultDownloadDialog

PostJsonWebMessage