javascript - create a menu dynamically to import in different web pages -


i'm creating app cordova framework, want create main menu generated dinamically javascript can import in different web pages.

i have next folder structure

|-folder |--index.html |--|reports |--|--index.html |--|--report.html |--js |--|--menu.js 

so if create menu index.html importing script menu.js result like

<div class="menu">   <ul>    <li><a href="#">home</a></li>    <li><a href="reports/index.html">reports</a></li>   </ul> </div> 

the other hand if import script reports/index.html href in items change.

this done mvc framework, project use jquery , don't want incorporate whole project framework. there simple way this?

you use absolute path names

<div class="menu">   <ul>    <li><a href="/folder/.../index.html">home</a></li>    <li><a href="/folder/.../reports/index.html">reports</a></li>   </ul> </div> 

if small html-only sites, go solution, if you’re planning sth. bigger, use php detect current page, or better use sort of framework you.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -