【问题标题】:Is is possible to embed a local html page inside another one?是否可以将本地 html 页面嵌入到另一个页面中?
【发布时间】:2022-01-02 16:54:42
【问题描述】:

如果我有两个 html 页面:index.html 和 embed.html。在 embed.html 中,我有一个随机的 html 页面。但是,我需要将它嵌入到 index.html 中。 我用这个:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div style="width:100%; padding-bottom:56.25%; position:relative; border: 2px solid black;">
        <iframe src="C:\\Users\\User\\OneDrive\\Desktop\\Web prog\\embed.html" style="position:absolute; top:0px; left:0px; 
        width:100%; height:100%; border: none; overflow: hidden;"></iframe>
      </div>
  </body>
</html>

在src属性中,我放了embed.html页面的路径。

当我运行 index.html 时。这是我在开发工具中得到的:

index.html:12 不允许加载本地资源:file:///C://Users//User//OneDrive//Desktop//Web%20prog//embed.html

index.html 中除了我为 iframe 标签指定的边框外,什么都没有出现

我怎样才能做到这一点?

【问题讨论】:

标签: html css iframe


【解决方案1】:

如果html 位于同一目录,请使用:

<iframe src="embed.html">

如果html 位于父目录,请使用:

<iframe src="../embed.html">

或者,如果您愿意,您可以使用绝对路径

<iframe src="file:///c:\Users\User\OneDrive\Desktop\Web prog\embed.html">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-14
    • 2013-11-30
    • 1970-01-01
    • 2021-09-10
    • 1970-01-01
    • 2018-11-23
    • 1970-01-01
    • 2021-01-10
    相关资源
    最近更新 更多