Home >Web Front-end >HTML Tutorial >HTML reuse skills_HTML/Xhtml_Web page production

HTML reuse skills_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:41:461434browse

HTML reuse is a rarely mentioned term. Today’s summary of this issue is as follows:
In old versions of browsers, HTML documents do not support nesting, and we need to be able to reuse HTML code. There are two main methods based on server-side and client-side implementation:
1. Server-side implementation
 a. Use SSI, which is a common shtml file.
Include statements for b.asp, php, etc., template pages and user controls for asp.net.

2. Implement
on the client side a. Use javascript client script
a1. You can trigger a js method in the onload event of the html document. In this method Find a page element as a container and output a piece of html code in the container (you can define a string to store the html code snippet to be output, such as: var str="

hello world!

";) .
a2. Use script registration blocks such as in the page (Default3.aspx here can also be a js script file Or other server-side output that implements js format), use the document.write method in the implemented script file to print out the html code to be reused.
a3. Implemented using AJAX. This method has a flaw, that is, some browsers on the client do not support ajax cross-site calls by default.
b. Use iframe

Choice between the two:
In more cases, the server-side implementation is preferred, unless the client-side implementation is used for some static pages or some special occasions. .

More references:
http://ask-leo.com/how_do_i_include_one_html_file_inside_another.html

http://www.boutell.com/newfaq/creating/include.html

http://blog.csdn.net/omohe/archive/2007/10/28/1850766.aspx

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