I have developed a website which I intend to display inside a webview, within a Chrome App. This works fine.
Now, I want to use postMessage from the website, to send messages out of the webview and into the containing Chrome App. This is done via top.postMessage inside the webview.
I've tried the following event listeners:
webView.contentWindow.addEventListener('message', messageHandler);
webView.addEventListener('message', messageHandler);
window.addEventListener('message', messageHandler);
document.addEventListener('message', messageHandler);
I have successfully implemented the following event listeners. All of which work as expected: contentload, dialog and consolemessage.
Unless I can get this to work, I am considering using consolemessage to send messages from the webview to the container - something I find unappealing, and I suspect it won't work when not using the developer mode.