【问题标题】:Chrome extension add iframe and access parent window contentChrome 扩展添加 iframe 并访问父窗口内容
【发布时间】:2015-05-13 04:50:06
【问题描述】:

我将内容脚本中的 iframe 注入到页面中。 iframe 运行一个角度应用程序。我想从此角度脚本访问父窗口的内容。我该怎么做?

部分清单.json

"content_scripts": [
    {
        "css": [
            "css/inject.css"
        ],
        "js": [
            "scripts/inject.js"
          ],
        "run_at": "document_end",
        "all_frames": false
    }
],
"web_accessible_resources": [
    "frame.html"
]

frame.html

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="css/angular-csp.css" type="screen">
        <title>name</title>
    </head>

  <body>
    <div class="popup" ng-app="popup" ng-csp>
        <div ui-view></div>
    </div>
    <script src="js/jquery/jquery.min.js"></script>
    <script src="js/angular/angular.min.js"></script>
  </body>
</html>

【问题讨论】:

    标签: angularjs iframe google-chrome-extension


    【解决方案1】:

    你不能直接做;跨域限制适用。

    相反,您需要向内容脚本发送消息,以便为您操作/查询页面。

    【讨论】:

    • 你能举个例子吗?
    • 在不知道自己想要做什么的情况下很难做到;但是,您应该专门研究Messagingthis function
    猜你喜欢
    • 2012-07-24
    • 2011-04-25
    • 1970-01-01
    • 2012-07-04
    • 2015-07-15
    • 2013-05-20
    • 1970-01-01
    相关资源
    最近更新 更多