简体   繁体   中英

How import html in another html file like php include() function

I want to include header and footer in all of my pages. I can include in php by using include() function. But I have only .html file. So is there any html markup to include another html file.

With jquery you can do an ajax request:

 $('footer').load('/yourPage.html', function () {
    //if you need to do something after
 });

Using HTML Imports

<head>
  <link rel="import" href="/path/to/file/file.html">
</head>

And use it with:

var content = document.querySelector('link[rel="import"]').import;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM