1

I want to use common footer in all pages in my website. I use this code for doing this:

index.html:

<html>
<head>
    <script src="js/jquery.min.js"></script>
    <script> 
    $(function(){       
      $("#generalFooter").load("footer.html"); 
    });
    </script>
</head>
<body>
    <div id ="generalFooter"></div>
</body>
</html>

footer.html:

<footer class="footer footer-distributed">
.
.
.
</footer>   

It's working , Actually I want to know is it the best way for calling static footer in all of pages?

Farzan Najipour
  • 2,442
  • 7
  • 42
  • 81
  • Check this out http://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file. With so many upvotes this must be the best solution you could get. – Nitin Varpe Feb 20 '16 at 10:18

2 Answers2

0

I think its the best solution to include an HTML file.

I tried your code and its working.

Please check the paths of jQuery file and the footer.html file.

Ashish
  • 468
  • 2
  • 8
  • 24
0

https://css-tricks.com/the-simplest-ways-to-handle-html-includes/

Use PHP

PHP offers a wonderful method to resolve this with the include() statement. With this technique we can include any file we want within another file.

    <body>

<!--header start -->
        <?php include("includes/header.php"); ?>
    <!--header end -->

<div clas"container"></div>


<!--footer start -->
    <?php include("includes/footer.php"); ?>
<!--footer end -->

</body>
Priya jain
  • 1,127
  • 2
  • 10
  • 22