html - 如何将一个 HTML 文件包含到另一个文件中?

标签 html

我已经在 stackoverflow 上尝试了所有可能的问题,但无法解决这个问题......

    <!--#include virtual="include.shtml"-->
    <!--#include virtual="include.html"-->
    <!--#include file="include.shtml"-->
    <!--#include file="include.html"-->
    <!--#include virtual="/include.shtml"-->
    <!--#include virtual="/include.html"-->
    <!--#include file="/include.shtml"-->
    <!--#include file="/include.html"-->
    <? include("/include.shtml"); ?>
    <? include("include.shtml"); ?>
    <? include("/include.html"); ?>
    <? include("include.html"); ?>

我尝试使用运行在 localhost/include/index.html 或 file:///home/sahil/Desktop/include/index.html 的 apache 服务器,上面包含所有内容,但它们都不适合我 :( .Now考虑到我的 index.html 和 include.html 都在同一目录中,我应该使用哪种方法将一个 HTML 文件包含到另一个文件中???

最佳答案

以前的语法是SSI , 后者是 PHP .两者都是服务器技术,只有从支持并配置为检查文件语法的 HTTP 服务器访问时才会工作(这通常意味着您必须打开支持并使用 .shtml/.php 文件扩展名(或更改从默认配置到确定要检查的文件))。其他服务器端技术可用。

HTML 本身唯一的“包含”机制是 (i) framesobjects .

您还可以考虑一个模板系统,例如 TT您可以将其作为构建步骤运行以生成静态 HTML 文档(注意:TT 也可以即时使用)。

关于html - 如何将一个 HTML 文件包含到另一个文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7542872/

相关文章:

javascript - 悬停时自动播放 html 视频?

html - 带固定页脚的全高侧边栏,内容固定宽度

html - Twitter Bootstrap 定制和下载

javascript - 为不起作用的动态字段创建添加按钮

html - 页脚的位置是不变的

javascript - 绝对定位元素的视差滚动问题

html - 我可以在 CSS 中更改负边距的重叠顺序吗?

javascript - 在响应式触摸设备中,复选框和单选按钮可从外部区域单击,如何解决这个问题?

javascript - 获取背景图片 url 值

Html5 CSS 表格边框在 IE 11 中不可见