如何将一个HTML文件包含到另一个? [英] How to include one HTML file into another?

查看:102
本文介绍了如何将一个HTML文件包含到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <! - #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.shtml); ?>
<?包括( include.shtml); ?>
<?包括( / include.html); ?>
<?包括( include.html); ?>

我尝试使用运行在localhost / include / index.html或file:/// home的apache服务器/sahil/Desktop/include/index.html与上述包括但他们都没有为我工作:(。现在我应该使用哪种方法包括一个HTML文件到另一个,考虑我的index.html和include.html都是在同一个目录中???前面的语法是 shtmlrel =noreferrer> SSI ,后者是 PHP 。两者都是服务器技术,只会如果从支持HTTP服务器并被配置为检查文件的语法(通常意味着您必须打开支持并使用.shtml / .php文件扩展名(或将配置从默认值更改为确定哪些文件需要检查))。其他服务器端技术可用。

HTML中唯一的include机制是(i) frames objects

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


I have tried every possible question here on stackoverflow but unable to resolve this issue ...

    <!--#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"); ?>

I tried with apache server running at localhost/include/index.html or file:///home/sahil/Desktop/include/index.html with all above includes but none of them is working for me :( .Now which method should i use to include one HTML file into another , considering my index.html and include.html both are in same directory ???

解决方案

The former syntax is SSI, the latter is PHP. Both are server technologies and will only work if accessed from an HTTP server that supports and is configured to check the file for the syntax (which usually means you have to turn the support on and use a .shtml/.php file extension (or change the config from the default to determining which files to check)). Other server side technologies are available.

The only "include" mechanisms in HTML itself are (i)frames and objects.

You could also consider a template system such as TT that you could run as a build step to generate static HTML documents (NB: TT can also be used on the fly).

这篇关于如何将一个HTML文件包含到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆