How To Make Reuseable HTML Navigation Menus?

前端 未结 10 826
面向向阳花
面向向阳花 2021-01-02 04:41

I\'m sure this topic comes up all the time,
But I can\'t seem to fine a concise answer.

I\'ve got a vertical menu bar that I want to reuse in webpages (>20)

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-02 05:22

    In order to do this, you'll have to use some server side technology. For instance you could...

    • include them in php

    • put them in the master page in .net

    • put this in a partial or a layout page in rails

    Some reading:

    http://us.php.net/manual/en/function.include.php

    http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx

    Another solution would be to create all this using Javascript, but please don't do it like that :)

    html:

    
    

    hack.js:

    function createMenu(){
      $("#mymenu").html("all the html of your menu");
    }
    

提交回复
热议问题