How to use # include file in HTML

Source: Internet
Author: User

There are two files a.htm and b.htm, under the same folder a.htm content such as the following

<!--#include file= "b.htm" -

B.htm content such as the following

Today: Rain 31℃~26℃<br/> Tomorrow: Thunderstorm 33℃~27℃

Open a directly in the browser, no matter what the display, and later know that include is SSI (Server Side include), in HTML does not support the include, The a.htm is then changed to a.aspx, and the page is posted on IIS, and then a.aspx can see the content. In the HTML to achieve this effect, the ability to use the IFRAME tag, directly on the Internet to find a sample example, such as the following:

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

How to use # include file in HTML

Number of references
PathType

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

Path type meaning
The file name is the relative path to the folder where the document with the #include command is located. The included file can be in the same folder or subfolder, but it cannot be in the upper folder of the page with the #include command.
The virtual file name is called the full virtual path to the virtual folder on the Web site.

FileName

Specifies the name of the file to include. FileName must include the file name extension, and the file name must be enclosed by an argument (").

Gaze
Files that include #include commands must use the file name extension that is mapped to the SSI interpreter, otherwise WEB server will not process the command. By default, the extension. stm,. shtm, and. sHTML are mapped to the interpreter (Ssinc.dll). Assuming you have Internet service Manager installed, you can change the default extension mappings and add new mappings. See Setting Application Mappings. The included files can have no file extensions, but it is recommended to give them the. inc extension.

Demo sample
<!--included files are present in the same folder as the parent file. -
<!--#include file = "Myfile.inc"-

<!--included files are located in the Script virtual folder. -
<!--#include virtual = "/scripts/tools/global.inc"-

The difference between include file and include virtual

1. #include file includes a relative path to the files, #include virtual includes the path to the file.
2. Within the same virtual folder,<!--#include file= "file.asp"-and <!--#include virtual= "file.asp"-the effect is the same, But if the virtual folder name is MyWeb, then <!--#include virtual= "myweb/file.asp" and can also be debugged, but we know <!--#include file= "myweb/file.asp "And it's definitely going to be an error.
3. Suppose that there are 2 virtual directories under a Web site Myweb1 and myweb2,myweb1 under the file File1.asp,myweb2 file file2.asp, assuming file1.asp to invoke File2.asp, So in file1.asp to write this:<!--#include virtual= "myweb2/file2.asp"--&gt, in such cases with # include file is not possible, with <!--#include File= "myweb2/file2.asp"--Must be an error. In contrast, the files included in the Myweb2 file are the same as those in the myweb1. Suppose the included file is below a directory, just add the directory to the virtual path.
4. Whether you use # include file or #include virtual, using "/" or "/" or both in the path will not affect the compilation effect, the program will run smoothly.
5. The above conditions do not apply to the mutual invocation of 2 Web site files, and within the same site,<!--#include file= "file.asp"-and <!--#include virtual= "file.asp"-equivalent , but if the site is named website, using <!--#include virtual= "website/file.asp"--is wrong.

How to use # include file in HTML

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.