gpt4 book ai didi

javascript - 需要在加载外部域的 iframe 上运行 javascript

转载 作者:行者123 更新时间:2023-11-30 13:42:16 28 4
gpt4 key购买 nike

mysite.com 有一个 iframe 加载一些 differentsite.com.

需要在此加载的 iframe 文档上运行 javascript。

单一来源政策开始。

我求助于使用代理。它很慢,造成瓶颈,无法完全呈现网站(不呈现 JS)。

备选方案?

最佳答案

您可以尝试 window.postMessage(message, origin)(它将是来自 iframe 的 parent.postMessageiframeElement.contentWindow.postMessage 从首页)适用于所有最新的主流浏览器(Firefox、IE、Safari、Chrome 等),并为旧浏览器更改/轮询 window.name

关于javascript - 需要在加载外部域的 iframe 上运行 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1619191/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com