Kapitol
Kapitol

Reputation: 153

Include a dynamic menu using JavaScript

I want to include a file based on the page name or another unique element using Javascript for each html page on my website.

The script would need to identify the element then load the correct file.

My website pages end with the extension .html -- If I could change them to .php I would and I would be set, but I cannot change the structure.

So for example, a script would check the beads.html for a unique element then it would load the beads-nav.html file that's associated with that element. jewelry.html would load the jewelry-nav.html file, etc.

Upvotes: 0

Views: 1518

Answers (1)

brains911
brains911

Reputation: 1310

You can load external pages via ajax.

With jquery it could be as easy as this: $('#result').load('ajax/test.html');

Taken from here.

Upvotes: 1

Related Questions