【问题标题】:IFrame with inline source (data:text/html...) gives a cross-domain error带有内联源 (data:text/html...) 的 IFrame 给出了跨域错误
【发布时间】:2018-01-12 14:12:06
【问题描述】:

我目前正在使用 javascript 制作 iframe,但是当我尝试使用 myIframe.contentWindow.document 访问 iframe 时,我收到以下错误:

DOMException: Blocked a frame with origin "http://localhost:8082" from accessing a cross-origin frame.

【问题讨论】:

    标签: iframe


    【解决方案1】:

    出于安全目的,您不能编辑 iframe 的内容。由于引发了跨域错误,您似乎正在尝试在 iframe 中设置内容。您可以将 iframe 的内容复制到另一个对象,然后对其进行编辑。

    如果这是真的需要考虑的事情......

    通过 jQuery 使用 AJAX..How to copy iframe content to div?

    如果使用 Chrome,请理解 Chrome 不支持本地 CORS...Deadly CORS when http://localhost is the origin

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-17
      • 2013-11-13
      • 2010-10-25
      • 1970-01-01
      • 1970-01-01
      • 2014-03-11
      相关资源
      最近更新 更多