Home  >  Article  >  Web Front-end  >  Introduction to usage examples of #include file in html_HTML/Xhtml_Web page production

Introduction to usage examples of #include file in html_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:38:081945browse

There are two files a.htm and b.htm. The content of a.htm in the same directory is as follows

Copy code
The code is as follows:



b.htm content is as follows

Today: Rain 31 ℃ ~ 26 ℃
Tomorrow: Thunderstorm 33 ℃ ~ 27 ℃

Open a directly in the browser, nothing is displayed. Later I found out that the include is SSI (Server Side Include ), include is not supported in html, then change a.htm to a.aspx, and publish the page on iis, and then you can see the content in a.aspx. If you want to achieve this effect in HTML, you can use the iframe tag. I found an example directly on the Internet as follows:

Copy code
The code is as follows:



Usage of #include file in html

Parameters

PathType

The path type of FileName. The path can be one of the following types:

Path type Meaning

File The file name is a relative path to the directory where the document with the #include command is located. The included file can be in the same directory or a subdirectory; but it cannot be in a directory above the page with the #include command.
Virtual filename The full virtual path to the virtual directory on the website.

FileName

Specifies the file name to include. FileName must include the filename extension, and the filename must be enclosed in quotation marks (").

Comments

Files containing #include commands must use a file extension that maps to the SSI interpreter ; Otherwise, the Web server will not process the command. By default, the extensions .stm, .shtm, and .shtml are mapped to the interpreter (Ssinc.dll). You can modify the default extension mapping if Internet Services Manager is installed. and add new mappings. See Setting Application Mappings. Included files can have any file extension, but it is recommended to give them the .inc extension.







include file and include virtual. Difference

1. #include file includes the relative path of the file, #include virtual includes the virtual path of the file.
2. In the same virtual directory, and have the same effect, but assuming the virtual directory is named myweb, then can also be debugged, but we know that will definitely report an error.
3. If There are two virtual directories myweb1 and myweb2 under a site. There is file file1.asp under myweb1 and file file2.asp under myweb2. If file1.asp wants to call file2.asp, then write this in file1.asp: < !--#include virtual="myweb2/file2.asp"-->, in this case it is impossible to use #include file, use An error is bound to be reported. On the contrary, the same is true for including the files in myweb1 in the files of myweb2. If the included file is under a folder, just add the folder to the virtual path.
4. Whether you use #include file or #include virtual, use "/" or "/" in the path, or use the two interchangeably, it will not affect the compilation effect, and the program will execute smoothly.
5. The above situation does not apply to mutual calls between two site files, and within the same site, and is equivalent, but assuming the site is named website, using is wrong.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn