zoukankan      html  css  js  c++  java
  • html中#include file的使用方法

    有两个文件a.htm和b.htm,在同一文件夹下a.htm内容例如以下

    b.htm内容例如以下

    直接在浏览器中打开a,没有不论什么显示,后来知道,include是SSI(Server Side Include),在html中不支持include,之后把a.htm改成a.aspx,而且在将该页面公布在iis上,然后a.aspx就能够看到内容了。在html中想达到这种效果,能够使用iframe标签,直接在网上找了个样例例如以下:

    html中#include file的使用方法

    參数
    PathType

    将 FileName 的路径类型。路径可为下面某种类型:

    路径类型 含义
    文件 该文件名称是带有 #include 命令的文档所在文件夹的相对路径。被包括文件可位于同样文件夹或子文件夹中;但它不能处于带有 #include 命令的页的上层文件夹中。
    虚拟 文件名称为 Web 网站上虚拟文件夹的完整虚拟路径。

    FileName

    指定要包括的文件名称。FileName 必须包括文件名称扩展,并且必须将文件名称用引號 (") 引起来。

    凝视
    包括 #include 命令的文件必须使用映射到 SSI 解释器的文件扩展名;否则,Web server将不处理该命令。默认情况下,扩展名 .stm、.shtm 和 .shtml 将映射到解释器 (Ssinc.dll)。假设安装了 Internet 服务管理器,则能够改动默认扩展映射并加入新的映射。请參阅设置应用程序映射。被包括的文件可具有不论什么文件扩展名,但建议赋予它们 .inc 扩展名。

    演示样例
    <!--被包括文件与父文件存在于同样文件夹中。 -->
    <!-- #include file = "myfile.inc" -->

    <!--被包括文件位于脚本虚拟文件夹中。 -->
    <!-- #include virtual = "/scripts/tools/global.inc" -->

    include file 与include virtual的差别

    1.#include file 包括文件的相对路径,#include virtual包括文件的虚拟路径。
    2. 在同一个虚拟文件夹内,<!--#include file="file.asp"-->和<!--#include virtual="file.asp"-->效果是同样的,但如果虚拟文件夹名为myweb,则<!--#include virtual="myweb/file.asp"-->也能够通过调试,但我们知道<!--#include file="myweb/file.asp"-->是绝对要报错的。
    3.假设一个网站下有2个虚拟目录myweb1和 myweb2,myweb1下有文件file1.asp,myweb2下有文件file2.asp,假设file1.asp要调用file2.asp,那么在file1.asp中要这样写:<!--#include virtual="myweb2/file2.asp"-->,在这样的情况下用#include file是无法实现的,用<!--#include file="myweb2/file2.asp"-->必定报错。相反,在myweb2的文件里包括myweb1中的文件也是一样。假设该被包括文件在某个目录以下,仅仅要在虚拟路径中加上该目录就可以。
    4.不论用#include file 还是 #include virtual,在路径中用“/”还是“/”或者二者交叉使用都不会影响编译效果,程序会顺利运行。
    5.以上情况不适用于2个网站文件的相互调用,并且在同一个网站内,<!--#include file="file.asp"-->和<!--#include virtual="file.asp"-->等效,但如果网站名为website,使用<!--#include virtual="website/file.asp"-->是错误的。

  • 相关阅读:
    MFC tab页面中获到其它页面的数据
    sqlite数据库中"Select * From XXX能查到数据,但是Select DISTINCT group From xxx Order By group却查不出来
    关闭程序出现崩溃(exe 已触发了一个断点及未加载ucrtbased.pdb)
    springboot 通用Mapper使用
    springBoot 发布war包
    springCloud Zuul网关
    springboot hystrix turbine 聚合监控
    springBoot Feign Hystrix Dashboard
    springBoot Ribbon Hystrix Dashboard
    springBoot Feign Hystrix
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4492378.html
Copyright © 2011-2022 走看看