Simulate PHP Include Without PHP

Viewed 10777

I want to include the same navigation menu on multiple pages, however I do not have PHP support, nor can I affect my server in any other way.

I want to avoid simply copying and pasting the html onto all the pages as this would make updating the menu a pain.

The two options I can think of are as follows:

1) Have all the content exist on one page, then determine which content to show based on a keyword appended to the url:

example.com/index?home
example.com/index?news

2) Include a javascript file that has a function that writes the menu out and call the function on each page

function setupMenu() {
    $("#nav").html("<ul class='nav'><li>home</li><li>news</li></ul>");
}

With Option 1, the updating process would consist of editing one nav menu on the one page

With Option 2, updating would mean changing the function in the javascript file

My concern with Option 1 is that the page would have to load a lot of content that it wouldn't need to display. My concern for Option 2 may seem trivial but it is that the code can get messy.

Are there any reasons doing it one way would be better than the other? Or is there a third superior option that I'm missing?

6 Answers
Related