【问题标题】:How to access webview content in chrome app如何在 chrome 应用程序中访问 webview 内容
【发布时间】:2014-06-06 20:09:31
【问题描述】:

我正在编写一个 chrome 应用程序,它通过 . 在加载的页面中执行 JavaScript 非常适合:

webview.executeScript();

但现在我需要在我的主 chrome 应用程序中从加载的外部站点读取 HTML 内容。

我怎样才能做到这一点?

【问题讨论】:

  • 注入内容脚本,在两者之间建立消息传递?
  • 嗨,Xan,你能提供一个代码示例或教程吗?

标签: javascript webview google-chrome-app


【解决方案1】:

您也可以为此使用 executeScript:

webview.executeScript(
    {code: 'document.documentElement.innerHTML'},
    function(results) {
      // results[0] would have the webview's innerHTML.
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-06
    • 1970-01-01
    • 2011-12-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多