How to load nav menu from an external file? (No Wamp, all code must be 'browser-side')

前端 未结 5 898
攒了一身酷
攒了一身酷 2020-12-12 07:22

I have a static HTML web site. I want to store the the nav (top) menu in an external file so when I change the menu, I want to see the change in all pages.
I RE

5条回答
  •  我在风中等你
    2020-12-12 08:02

    A copy of my answer on a different thread:

    I think this is the easiest way of doing it without a server side language. Use a javascript library like W3Data. All you need to do is add the w3-include-html attribute to your div. Done!

    If your menu is in a file called menu.html you'd do something like this.

提交回复
热议问题