Go Back   HTMLCenter Web Development Forums > Web Design and Development > Programming and Scripting

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-14-2008, 05:18 PM
Registered User
 
Join Date: Jul 2008
Posts: 1
CSS and Java Script Menu - need help!

I'm working on something that is probably very simple, but i'm a newbie with Java scrip.
Here's the CSS:

/* Menu*/
#menu {
float: right;
list-style: none;
padding: 0;
margin: 0;
width: 161px;
height: 160px;
background: transparent;
position: relative;
}
#menu span {
display: none;
position: absolute;
}
#menu a {
display: block;
text-indent: -1000%;
position: absolute;
outline: none;
}
#menu a:hover {
background-position: left bottom;
}
#menu a:hover span {
display: block;
}

#menu .about {
width: 161px;
height: 34px;
background: url(images/About.png) no-repeat;
left: 0px;
top: 0px;
}

#menu .about span {
width: 161px;
height: 34px;
background: url(images/AboutOver.png) no-repeat;
left: 0px;
top: 0px;
}

#menu .news {
width: 161px;
height: 41px;
background: url(images/News.png) no-repeat;
left: 0px;
top: 34px;
}

#menu .news span {
width: 161px;
height: 41px;
background: url(images/NewsOver.png) no-repeat;
left: 0px;
top: 0px;
}

#menu .music {
width: 161px;
height: 37px;
background: url(images/Music.png) no-repeat;
left: 0px;
top: 75px;
}

#menu .music span {
width: 161px;
height: 37px;
background: url(images/MusicOver.png) no-repeat;
left: 0px;
top: 0px;
}

#menu .contact {
width: 161px;
height: 48px;
background: url(images/Contact.png) no-repeat;
left: 0px;
top: 112px;
}

#menu .contact span {
width: 161px;
height: 48px;
background: url(images/ContactOver.png) no-repeat;
left: 0px;
top: 0px;
}

and the HTML:

<div id="menu">
<ul id="menu">
<li><a href="About.htm" class="about">About <span></span></a></li>
<li><a href="News.htm" class="news">News <span></span></a></li>
<li><a href="Music.htm" class="music">Music <span></span></a></li>
<li><a href="Contact.htm" class="contact">Contact <span></span></a></li>
</ul>
</div>

Ok, so what I want to do is add Java script so that (for example) when i click on "About" the image in the menu is "AboutOver" not the original "About" image.... Basically, just a way for people to tell which page they're on.

I don't know much of anything about Java script, though i know it all has something to do with the onClick....

Help please?!
Reply With Quote

  #2 (permalink)  
Old 07-15-2008, 01:00 AM
Leprakawn's Avatar
Moderator
 
Join Date: Jan 2004
Location: Outside, and playing with your invisible friends.
Posts: 1,109
Send a message via AIM to Leprakawn Send a message via Yahoo to Leprakawn
Something like this?
HTML Code:
<a href="the-page-you-desire.htm" onmouseover="document.Buddy_Holly.src='file/name-mo.jpg'" onmouseout="document.Buddy_Holly.src='file/name-me.jpg'"> 
<img src="file/name-me.jpg" name="Buddy_Holly" alt="Alternate txt goes here" /> 
</a>
To analyze this:

href="" is what you are linking to
onmouseover="" is the mouseover effect, or the img you will see when the mouse is over that img. KEY NOTE: Make sure to give your imgs different names, and use those names in the document.**.src section. And the src is where these other imgs are located.

onmouseout is what you will see when the mouse leaves the button. Of course you could get a little fancy and have an onmouseup="" applied to it (same coding within quotes), to make it even more interactive.

That is my 02˘ for the night.
__________________
Like my spiffy, unique signature?
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

Last edited by Leprakawn : 07-15-2008 at 01:03 AM.
Reply With Quote
  #3 (permalink)  
Old 07-15-2008, 10:15 AM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,391
The way you have it set up right now, you don't need javascript to accomplish what you want. You just need CSS.

Look into the :hover property.

Code:
#menu .about {
width: 161px;
height: 34px;
background: url(images/About.png) no-repeat;
left: 0px;
top: 0px;
}

#menu .about span {
width: 161px;
height: 34px;
background: url(images/AboutOver.png) no-repeat;
left: 0px;
top: 0px;
}
Would become:
Code:
#menu a.about {
width: 161px;
height: 34px;
left: 0px;
top: 0px;
}

#menu a.about:link, #menu a.about:visited {
background: url(images/About.png) no-repeat;
}

#menu a.about:hover {
background: url(images/AboutOver.png) no-repeat;
}
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java script plays same "wav" everytime seccondbest Programming and Scripting 0 07-23-2007 06:55 PM
css and java script combined for drop down seccondbest Programming and Scripting 2 11-25-2006 08:30 AM


All times are GMT -5. The time now is 04:51 PM.

 
KickApps
Clicky Web Analytics


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter