Detailed introduction to the usage of #include file in html

高洛峰
Release: 2017-03-04 15:35:26
Original
5263 people have browsed it

This article mainly introduces the usage of #include file in html. I personally feel that the tutorial is pretty good and suitable for beginners. Friends who need it can refer to it. There are two files a.htm and b.htm. In the same directory, the content of a.htm is as follows

The code is as follows:

<!-- #include file="b.htm" -->
Copy after login


The content of b.htm is as follows

Today: Rain 31 ℃ ~ 26 ℃
Tomorrow: Thunder shower 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:

The code is as follows:

<iframe frameborder=0 border=0 width=300 height=300 src="b.htm" mce_src="b.htm"></iframe>
Copy after login


html #include file usage

Parameters

PathType

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

Path type Meaning

File The file name is the 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 Web site.

FileName

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

Notes

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 will 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.

For more detailed introduction to the usage of #include file in html, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!