How to introduce other HTML pages into HTML pages

How to introduce other HTML pages into HTML pages

In daily development, the written HTML pages are often not independent or mutually exclusive, usually some head, tail or other parts are common, but HTML has different JSP pages that can use action tags like include, so the next introduction A method of introducing other HTML pages into an HTML page.

The first way:
1. Write an include.js, write part of the public page into it

$(function () {
    
    
    $.get("header.html",function (data) {
    
    
        $("#header").html(data);
    });
    $.get("footer.html",function (data) {
    
    
        $("#footer").html(data);
    });
});

Insert picture description here

2. Import, just use a DIV and fill in the id name above to import the
Insert picture description here
second way:

<iframe src="header.html" width="100%" frameborder="0" scrolling="no"></iframe>

src: HTML file to be imported
width: width
frameborder: border
scrolling: scroll bar

Guess you like

Origin blog.csdn.net/weixin_49092628/article/details/110749033