首页 > 解决方案 > Firefox 阻止加载 HTML iframe

问题描述

我想使用 HTML iframe 加载另一个页面,但由于避免安全问题,Firefox 阻止了它。.

我试图将“https”更改为“http”,但它不起作用。

Firefox 显示的错误:

Firefox Can’t Open This Page 
To protect your security, anouar.stencila.io will not allow Firefox to display the page if another site has embedded it. To see this page, you need to open it in a new window.

这是使用的代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Reproducible Article</title>
  </head>

  <body>
    <!-- The header of the file -->
    <p>
      <a
        href="https://ojs3.josekarvalho.net/index.php/rp/article/view/87/176"
        target="_blank"
        >Link to HTML version</a
      >
      |
      <a
        href="https://ojs3.josekarvalho.net/index.php/rp/article/view/87/181"
        target="_blank"
        >Link to PDF version</a
      >
    </p>

    <!-- The iframe to be shown - the link to the reproducible article allowfullscreen -->
    <iframe
      src="https://anouar.stencila.io/gentsch2020/"
      frameborder="0"
      style="position: absolute; top: 80px; left: 0; width: 100%; height: 100%"
      scrolling="yes"
      title="Reproducible Article"
    ></iframe>
  </body>
</html>

标签: htmlfirefoxiframe

解决方案


页面https://anouar.stencila.io/gentsch2020/提供以下X-Frame-Options标头:

x-frame-options: allow-from *.ojs3.josekarvalho.net

ALLOW-FROM任何最新的浏览器都不支持,所以它不会工作。您要么需要尽可能使用SAMEORIGIN,要么完全删除标题。

X-Frame-Options 可以替换为Content-Security-Policy: frame-ancestors <source>;,请参阅MDN


推荐阅读