HTML reuse is a rarely mentioned word. Today, the summary of this issue is as follows:
In old versions of browsers, HTML documents do not support nesting, but we need to be able to reuse HTML code. The usual practices are mainly two major methods based on server-side and client-side implementation:
1. Server-side implementation a. Use SSI, both the usual shtml file.b. include statements such as asp, php, etc., template pages and user controls of asp.net.
2. Implement on the clienta.Use JavaScript client script
a1. A js method can be triggered in the onload event of the html document, and a page element can be found as a container in the method, and a piece of html code can be output in the container (a string can be defined to store the html code snippet to be output, such as: var str=<p>hello world!</p>;).
a2. Use <script type=text/javascript src=Default3.aspx></script> and other scripts to register blocks (the Default3.aspx here can also be a js script file or other server-side output that implements js format), and use the document.write method to print out the html code to be reused in the implemented script file.
a3. Use AJAX to implement. This method has a flaw, that is, some browsers of the client do not support cross-site calls of ajax by default.
b.Use iframe
Choices of both:
In more cases, the server-side implementation is preferred, unless the client-side implementation is used in some pages that implement statically or in 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