|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Graphics & Design Discussion Forum Post your graphics design questions/comments/ideas in here. Ask questions, post tutorials, discuss trends and best practices. Sub-forum for website accessibility and usability. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello!
How can I create an image that changes on hover? I've tried one script at LissaExplains.com, but it didn't seem to work. Could someone please give me their code? Thanks, Mike
__________________
Wise WizardsŪ Website Design :: Professionally Designed Websites at Affordable Prices |
|
||||
|
Lots and lots of ways to do this! You can use CSS rollovers if you feel like being adventurous. If you're just after a straightforward Javascript example.. here's one that I've used in the past. Obviously, you're going to need two images.. one will be your "hover" image, the other your regular image that will be there initially and "onmouseout".
Place this first bit of code in the <head> of your page: Code:
<script language="javascript" type="text/javascript">
<!--
if (document.images)
{
navbutton1on= new Image(put-your-imagewidth-here,your-image-height);
navbutton1on.src="navbutton1-over.gif";
navbutton1off= new Image(your-image-width,your-image-height);
navbutton1off.src="navbutton1-off.gif";
}
function m_over(imgName)
{
if (document.images)
{
imgOn=eval(imgName + "on.src");
document[imgName].src= imgOn;
}
}
function m_out(imgName)
{
if (document.images)
{
imgOff=eval(imgName + "off.src");
document[imgName].src= imgOff;
}
}
//-->
</script>
Code:
<a href="#" onmouseout="m_out('navbutton1')" onmouseover="m_over('navbutton1')">[img]navbutton1-off.gif[/img]
Let me know how you get on! :o) Paul |
|
|||
|
Thanks, that's exactly what I wanted. I'll try it out ASAP!
Thanks, Mike P.S. Do I just substitute my image info into the HEAD script only, or do I also substitute the image into the BODY script?
__________________
Wise WizardsŪ Website Design :: Professionally Designed Websites at Affordable Prices |
|
|||
|
What if I want more than one button? Do I have to copy both scripts in as many times as I have buttons?
Regards, Mike
__________________
Wise WizardsŪ Website Design :: Professionally Designed Websites at Affordable Prices |
|
||||
|
|
|
|||
|
Thanks, I'll try out some new ways and find the one that's best for me.
Regards, Mike
__________________
Wise WizardsŪ Website Design :: Professionally Designed Websites at Affordable Prices |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |