HTML reuse skills


HTML reuse is a rarely mentioned word. Today, the summary of this problem is as follows:
In the old version of browsers, HTML documents do not support nesting, but we should be able to reuse HTML code. The common methods mainly include two categories of methods based on server-side and client-side implementation:
1. Server side implementation
A. use SSI, the usual shtml file.
B. include statements of ASP and PHP, template pages and user controls of

2. 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, you can 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 fragment to be output, such as var STR = “< p > Hello world</ p>”;)。
A2. Use script registration blocks such as < script type = “text / JavaScript” SRC = “default3. ASPX” > < / script > in the page (default3.aspx here can also be a JS script file or other server-side output that implements JS format), and print the HTML code to be reused in the implemented script file with the document.write method.
A3. Implement using Ajax. One drawback of this method is that some browsers on the client do not support Ajax cross site calls by default.
B. use iframe

Choice of both:
In most cases, the server-side implementation is preferred, unless the client-side implementation is used on some static pages or on some special occasions.

More references:

Recommended Today

Swift advanced (XV) extension

The extension in swift is somewhat similar to the category in OC Extension can beenumeration、structural morphology、class、agreementAdd new features□ you can add methods, calculation attributes, subscripts, (convenient) initializers, nested types, protocols, etc What extensions can’t do:□ original functions cannot be overwritten□ you cannot add storage attributes or add attribute observers to existing attributes□ cannot add parent […]