html - javascript menu in single file with current document location telling what menu in file to show -


i know if it's possible store menu in single javascript file , each consequent links document location read specific menu set in single page below

menu start home should show on home page

document.write('<ul>');     document.write('<li>');     document.write('<a href="index.html">home</a>');     document.write('</li><li>');     document.write('<br /><li>');     document.write('<a href="link1.html">link1</a>');     document.write('</li><br><li>');     document.write('<a href="link2.html">link2</a>');     document.write('</li><br><li>');     document.write('<a href="link3.html">link3</a>');     document.write('</li> document.write('</ul>'); 

menu 1 should show on page link1

document.write('<ul>');     document.write('<li>');     document.write('<a href="index.html">home</a>');     document.write('</li><li>');     document.write('<br /><li>');     document.write('<a href="link1.html">link1</a>');     document.write('</li><br><li>');     document.write('<a href="link1.1.html">link1.1</a>');     document.write('</li><br><li>');     document.write('<a href="link1.2.html">link1.2</a>');     document.write('</li><br><li>');     document.write('<a href="link1.3.html">link1.3</a>');     document.write('</li><br><li>');     document.write('<a href="link2.html">link2</a>');     document.write('</li><br><li>');     document.write('<a href="link3.html">link3</a>');     document.write('</li> document.write('</ul>'); 

menu 2 should show on page link2

document.write('<ul>');     document.write('<li>');     document.write('<a href="index.html">home</a>');     document.write('</li><li>');     document.write('<br /><li>');     document.write('<a href="link1.html">link1</a>');     document.write('</li><br><li>');     document.write('<a href="link2.html">link2</a>');     document.write('</li><br><li>');     document.write('<a href="link2.1.html">link2.1</a>');     document.write('</li><br><li>');     document.write('<a href="link2.2.html">link2.2</a>');     document.write('</li><br><li>');     document.write('<a href="link2.3.html">link2.3</a>');     document.write('</li><br><li>');     document.write('<a href="link3.html">link3</a>');     document.write('</li> document.write('</ul>'); 

menu 3 should show on page link3

document.write('<ul>');     document.write('<li>');     document.write('<a href="index.html">home</a>');     document.write('</li><li>');     document.write('<br /><li>');     document.write('<a href="link1.html">link1</a>');     document.write('</li><br><li>');     document.write('<a href="link2.html">link2</a>');     document.write('</li><br><li>');     document.write('<a href="link3.html">link3</a>');     document.write('</li><br><li>');     document.write('<a href="link3.1.html">link3.1</a>');     document.write('</li><br><li>');     document.write('<a href="link3.2.html">link3.2</a>');     document.write('</li><br><li>');     document.write('<a href="link3.3.html">link3.2</a>');     document.write('</li> document.write('</ul>'); 

the html file

i think menu 1, 2 , 3 in javascript page should have dedicated name when current document location link3.html or link3.1.html ... javascript find , show menu 3. possible in simple way?

thanks on this.

pascal

you need isolate name of page wish find, set whatever menu wish show. this answer shows pretty example how sniff url page name


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -