cordova-chrome-app

“Chrome Apps” webview.executeScript access guest global varibles

隐身守侯 提交于 2019-12-11 04:28:25
问题 I can access a Chrome App Webview HTML with: webview.executeScript( {code: 'document.documentElement.innerHTML'}, function(results) { // results[0] would have the webview's innerHTML. }); But I would like to get the value of global variables in the Guest like so: webview.executeScript( {code: 'window.globalVar'}, function(results) { // results[0] should have the webview's value of "globalVar". }); How can I do this? 回答1: An answer to summarize the steps required. 1) You inject a content

How to communicate with WebView in Chrome App?

拟墨画扇 提交于 2019-11-30 19:26:58
问题 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);