WebMessageReceived

Description

Occurs when a message sent by JavaScript on the web is received.

You can send a message from Web (JavaScript) to the PowerBuilder application (PowerScript) by executing the following JavaScript on the web:

window.chrome.webview.postMessage(`SetTitleText ${titleText.value}`); 

Or

window.webBrowser.postMessage(`SetTitleText ${titleText.value}`);

Syntax

WebMessageReceived (string uri, boolean isJson, string webmessage)

Event ID

Event ID

Objects

None

Webbrowser controls

Arguments

Argument

Description

uri

The URI of the DOM webpage that sends this message.

isJson

Whether the message is in the JSON format.

TRUE indicates that the message is in the JSON format; FALSE indicates the message is not in the JSON format.

webmessage

The received message, which can be in the JSON format or a string.


Return Values

None

Examples

This example shows how a message sent by JavaScript on the web is received.

//webmessagereceived(string uri, Boolean isjson, string webmessage)
//window.chrome.webview.postMessage('getweburl:' + document.URL)
If Len(WebMessage) > 0 Then
 Choose Case Left(WebMessage, Pos(WebMessage,":"))
  Case 'getweburl:'
   w_message lw_msg
   OpenWithParm( lw_msg, uri )
  Case Else
   //
 End Choose
End If

See also

AcceleratorKeyPressed

ContentLoading

HistoryChanged

DOMContentLoaded

NavigationCompleted

EstimatedEndTimeChanged

IsDefaultDownloadDialogStateChanged