Methods for sharing the head and tail of a webpage. Methods for sharing the head of a webpage
The head and tail of the same website are usually the same. As long as all webpages share the head and tail, maintenance of the webpage becomes much easier, you only need to modify one page to change the header and tail of all webpages. Here I try to use several different methods related to the course to achieve this:
Method 1: Use js to find an html-to-js website and convert the html code in your header into js Code.
Add <script language = "JavaScript" type = "text/javascript" src = "js/header. js"> </script>
The src = "js/header. js" path is the path of your head. js file.
This method can display the webpage content normally:
This method is convenient and easy to modify. The disadvantage is that because the search engine does not understand javascript files, the header files and tail files cannot be included by the search engine.
Method 2: Use the iframe framework
Create a common header file head.htmor a common background file foot.htm. To call the header and the bottom file, add the following code at the beginning and end of the webpage code:
<Iframe src = "head.html" width = "100%" height = "auto" marginwidth = "0" marginheight = "0" frameborder = "0" scrolling = "no"> </ iframe>
<Iframe src = "foot.html" width = "100%" height = "auto" marginwidth = "0" marginheight = "0" frameborder = "0" scrolling = "no"> </ iframe>
For this method, I don't know if my opening method is incorrect, and the display of the header is not ideal: only a straight line is displayed .. This method is not recommended.
Method 3: use ASP or PHP
First, create a header file head. php or a bottom file foot. php.
For example, if the homepage is index. asp, the code of calling the header is at the beginning of the code of the index. asp file (after the first mark, before the
<!– #include file=”head.php” –>
The code for calling the shared bottom file is to add the following code to the end position of the index. asp file code (before the last mark:
<! -# Include file = "foot. php"->
This method is pending ..