Jump to content

how do set up a javascript linked nav bar?


porzant

Recommended Posts

ive tried lots of help sites, but dont know how to do it. this is my html nav bar.

<table border="5"><tr><td><font face="Comic Sans MS" font size="2"><a href="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors.html"><font style="color:#C0C0C0">Home</a></td></tr><tr><td><font face="Comic Sans MS" font size="2"><a href="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Members.html"><font style="color:#C0C0C0">Members</a></td></tr><tr><td><font face="Comic Sans MS" font size="2"><a href="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Events.html"><font style="color:#C0C0C0">Events</a></td></tr><tr><td><font face="Comic Sans MS" font size="2"><a href="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20History.html"><font style="color:#C0C0C0">History</a></td></tr><tr><td><font face="Comic Sans MS" font size="2"><a href="http://www.freewebs.com/chrome_warriorsa/Application.html"><font style="color:#C0C0C0">Application</a></td></tr><tr><td><font face="Comic Sans MS" font size="2"><a href="http://www.freewebs.com/chrome_warriors/Stats.html"><font style="color:#C0C0C0">Stats</a></td></tr><tr><td><font face="Comic Sans MS" font size="2"><a href="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Forum.html"><font style="color:#C0C0C0">Forum</a></td></tr><tr><td><font face="Comic Sans MS" font size="2"><a href="http://www.freewebs.com/chrome_warriors/Videos.html"><font style="color:#C0C0C0">Videos</a></td></tr></table>

I have this on lots of pages, so it is annoying when i have to change it. could somebody please write the javascript code i would put into each page, linking it to this (so it displays on the page), and i would only have to change this for it to change on all of the other pages.thx for the help

Edited by Jonas
Link to comment
Share on other sites

looking at this post: http://w3schools.invisionzone.com/index.php?showtopic=2845 i think it is the kind of thing i want, so this is what it looks like now:

document.write(" \ <a href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors.html" >Home \  <p></p> \ <a href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Members.html" >Members \  <p></p> \ <a href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Events.html" >Events \  <p></p> \ <a href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20History.html" >History \ <a href ="http://www.freewebs.com/chrome_warriorsa/Application.html" >Application \  <p></p> \   <a href ="http://www.freewebs.com/chrome_warriors/Stats.html" >Stats \  <p></p> \   <a href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Forum.html">Forum \  <p></p> \ <a href ="http://www.freewebs.com/chrome_warriors/Videos.html" >Videos\  <p></p>  \ ")

Link to comment
Share on other sites

so would this work now?

document.write("<div class = "body"> \document.write<a class="body" href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors.html">Home\document.write<p></p> \document.write <a class="body" href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Members.html" >Members \document.write<p></p> \document.write <a class="body" href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Events.html" >Events \document.write<p></p> \document.write <a class="body" href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20History.html" >History \document.write<a class="body"href="http://www.freewebs.com/chrome_warriorsa/Application.html">Application \document.write<p></p> \document.write <a class="body" href ="http://www.freewebs.com/chrome_warriors/Stats.html" >Stats \document.write<p></p> \   document.write <a class="body" href ="http://www.freewebs.com/chrome_warriors/Chrome%20Warriors%20Forum.html">Forum \document.write<p></p> \document.write <a class="body" href ="http://www.freewebs.com/chrome_warriors/Videos.html" >Videos\document.write<p></p>  \ </div>")

Link to comment
Share on other sites

something like this: document.write('<div class="body">');document.write('<a class="body" href="#">Home</a>');document.write('<a class="body" href="#">Members</a>');document.write('<a class="body" href="#">Events</a>');document.write('<a class="body" href="#">History</a>');document.write('<a class="body" href="#">Application</a>');document.write('<a class="body" href="#">Stats</a>');document.write('<a class="body" href="#">Forum</a>');document.write('<a class="body" href="#">Videos</a>');document.write('</div>');

Link to comment
Share on other sites

The problem with generating something as fundamental as a nav bar in javascript is that it leaves anyone who has javascript disabled without a nav bar. If you have to include the exact same thing in many HTML files, I'd suggest you research INCLUDE files (though whether you can use them or not depends on things like what server you are using, and what language if any). Hope this helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...