首页 > 解决方案 > 试图访问某些网站的 HTML 并将其传输到弹出 IFRAME - 但无法获取它

问题描述

我正在尝试通过 iframe 和 google chrome 扩展获取网站的 HTML 文档,该扩展将 JS 注入到我能够弹出窗口的网站,但我无法获取“父”文档 - 只有孩子。这是我注入网站的代码:

   let msg = window.document;
let child_url = "https://localhost:3000"
function sendData(){
let ref=window.open(child_url,"pop","width=450,height=650,resizable=1");
  ref.postMessage('here i want to send the html document', 'https://www.ikea.co.il');
    
}
sendData();

这是我的 index.html 中的事件监听器(这是一个 vue 应用程序)

<script>
  window.addEventListener("message", function(e) {
    console.log(e);
  });
</script>

不知何故,控制台只记录了我添加的代理服务器的孩子的 html 文档,它们都是 HTTPS 协议

标签: javascriptvue.jsiframecross-domain

解决方案


推荐阅读