Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

speakerwizard

macrumors 68000
Original poster
Aug 8, 2006
1,655
0
London
Hi guys, im adding html to my iweb site after publishing to a folder using this technique: http://karreth.com/iweb/Rollover Images.html

<a href="whatever.html"
onMouseout="document.images['example'].src=img1.src"
onMouseover="document.images['example'].src=img2.src">
<img src="logo.png" name="example" border=0></a>

<script language="javascript1.2">
<!--
img2=new Image()
img2.src="logo2.png"
img1=new Image()
img1.src="logo.png"

//-->
</script>

if i use this once in a page its fine but if i want to do a second button i have problems, do i need to change the code to something like img3 and img4 for the next button? and do i have to even if i use the same button images? thanks in advance
 

speakerwizard

macrumors 68000
Original poster
Aug 8, 2006
1,655
0
London
hhmm, no, tried it with img3 and 4 to see if it conflicted but still no rollover once i add the second one in.
 

slooksterPSV

macrumors 68040
Apr 17, 2004
3,544
306
Nowheresville
PHP:
<script language="javascript">
function switchLogo()
{
if(a == 0)
{
 img1.src = "logo1.png"
 a = 1
}else if(a == 1)
{
 img1.src = "logo2.png"
 a = 0;
}
}
</script>

Or you could do it with onmouseover and onmouseoff or is it onmouseoff

Then you can just setup image 2 to be the same way, img2.src = "logo1.png" using the same manner, there's no easier way to do it I think, execpt if you made it via... um... using a WYSIWYG editor
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.