View Full Version : Navigation Menu Help

03-29-2008, 11:08 AM
Hello I am trying to create a horizontal tab menu with java script and html.
I want one of the tabs "terms" to appear on its on state by default when page loads. How do I do that. I have already created the rollover images. How do I get one of the tabs to be on the rolled over image by default?

image1 = new Image();
image1.src = "images/nav1_on.gif";

image2 = new Image();
image2.src = "images/nav2_on.gif";


<a href="index.htm" onmouseover="image1.src='images/nav1_on.gif';"
<img name="image1" src="images/nav1_off.gif" border=0></a>

03-29-2008, 11:25 AM
Could you show us a link on the page that you are referring?..
What about changing the default image on load?

<img name="image1" src="images/nav1_off.gif" border=0>

..Use images/nav1_on.gif instead :)

03-29-2008, 11:59 AM
I do not have it up and running yet. but was looking for a page lode event that would select the rolover image by default

03-29-2008, 12:15 PM
...But my point is, it has the same function as changing the image from the image tag :)
Anyway, you might have a reason behind it, i'll just show you this example:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
window.onload = function()
document.getElementById('image1').src = 'images/nav1_on.gif';

document.getElementById('clickme').onmouseover = function()
document.getElementById('image1').src = 'images/nav1_on.gif';
document.getElementById('clickme').onmouseout = function()
document.getElementById('image1').src = 'images/nav1_off.gif';
<a href="index.htm" id="clickme">
<img name="image1" src="images/nav1_off.gif" border=0></a>

Ideally, it has your wish of having images/nav1_on.gif as the default image during onload :)

Just a suggestion, you should (if possible) avoid combining presentation (JS) from markups (HTML). See example :)

See if it helps ;)

03-29-2008, 01:04 PM
Thanks I will try it out. Its an assignment and unfortunately that short cut of just swithcinh the image has been banned. one uestion why should I avoid combining the two? Whats the problems?

03-30-2008, 09:07 AM
Problem?..not really a problem, it's just to make your HTML more simple to look ;)
There are some validation errors that results in placing JS in Markups, anyway this will not bug you. ;)