How to nest an HTML page in another page

Source: Internet
Author: User
Tags net command apache tomcat

Embed a different page in the original page

1. Using the IFRAME framework

Client page nesting can use the method of the IFRAME, the disadvantage is that you have to think about how the nested pages in the first page to occupy a large position.

If the nested page is too large to exceed the predefined width or height, the scroll bar appears on the first page. This may be exactly what you need,

But it may completely ruin the design of the homepage.

< iframe >------</iframe >

<iframe src= "The URL or file to be placed inside the frame" height= "width=" "> </ifrmae>

Example: <iframe src= "text.asp" height= "width=" >

<a href= "text.asp" >

Your browser does not support IFRAME page nesting, please click here to access the page content.

</a>

</ifrmae >

The additive attribute scrolling= "No" means that the scrollbar does not appear with the content changing--excess content is automatically hidden!

frameborder= "0" nested page borders

leftmargin= "0" left margin

topmargin= "0" top margin

Onscroll= "True" executes the script when the element scroll bar is scrolled and defines the element in HTML 5

Insert <a>is because the old version of the browser and search engine does not support IFRAME, although now

Few people will use Netscape 4 as an old browser, but almost everyone will use a search engine like Google.

Adding hyperlinks to the IFRAME can help search engines find the content of the page.

2. SSI (Server Side Include)

SSI is a simple dynamic web authoring technology, but some servers require a Web page file extension of. shtml to identify the SSI command in the file. So if your SSI command doesn't seem to work, do not give up and try to change the file extension to. shtml, which may be successful. If you know if your server supports SSI, see another article.

One limitation of using SSI is that the page must be placed on a Web server to see the effect, which is poorly debugged locally. Of course, if you want to debug locally, you can install an Apache server locally.

For example, you want to add the same copyright information at the bottom of each page, like

? 2009 Programmer's Lab All rights reserved

This line of information can be placed in a file called footer.html, the contents of footer.html:

<center> &copy; Programmer's lab All rights reserved </center>;

The SSI command to include footer.html for other paging files under the same path is:

<!-#include virtual= "footer.html" (Common)

Or

<!-#include file= "footer.html"

The two are almost the same, except that the include virtual takes a path in the form of a URL, and can even execute a CGI program and include its output if your server supports CGI. The include file is followed by a filesystem path, and the CGI program cannot be executed. Both can accept relative paths, so for the simple example above, the effect is the same. If you don't know the difference between the URL path and the file system path, use the Include virtual

3. asp and ASP.

If you are using an old-fashioned ASP, the syntax is the same as the above SSI and does not require any modification, as long as the command file extension is changed to. asp.

For ASP. NET, the difference is that because SSI commands are compiled first before the ASP command is run, the variables in the file name cannot be used with ASP. If you must use it, use the ASP. NET command to do file nesting.

Like what:

<%          response.writefile ("footer.html")%>

For more information on how to implement dynamic file nesting in ASP, please refer to this article from Microsoft.

4. PHP

If your server supports PHP, use PHP to refer to the footer.html file as follows:

<?php include ("footer.html");?>

The file name extension for this command must be. php.

In addition to referencing the files on this server, the include command in PHP can also be used to reference HTML files on other Web sites, such as:

<?php include (http://www.prglab.com/examples/footer.html);?>

Of course you have to get permission from other websites to refer to other people's files.

5. JSP (Java Server Page)

JSP files need to be run on a Java-based server, such as Apache Tomcat. The syntax for the JSP include file is:

<%@ include file= "footer.html"%>

How to nest an HTML page in another page

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.