The action returns an object with two properties:
Property | Value |
"webViewId" | If applicable, a number containing an ID that uniquely identifies the web view from which this action is executing. |
"webViews" | An array containing details about each web view currently showing. The topmost showing web view is the first entry in the array. |
{
"webViewId": 19917272,
"webViews": [
{
"webViewId": 19917272
},
{
"webViewId": 21877240
}
]
}
The first web view ID in the array represents the web view showing the HTML dialog, and the second web view ID represents the web view showing the question text.
The action does not throw exceptions.
<script>
const CS = new CSProActionInvoker();
// there should be at least two web views since the question text is showing
const webViews = CS.UI.enumerateWebViews();
console.assert(webViews.webViews.length >= 2 && webViews.webViewId == webViews.webViews[0].webViewId);
// post a web message to the question text, which will be the last web view in the array
CS.UI.postWebMessage({
message: `Posting a message to the question text window at ${new Date().toISOString()}.`,
webViewId: webViews.webViews[webViews.webViews.length - 1].webViewId
});
</script>