simple html/javascript help, please (rollover)

Discussion in 'Mac Programming' started by speakerwizard, May 17, 2007.

  1. speakerwizard macrumors 68000

    speakerwizard

    Joined:
    Aug 8, 2006
    Location:
    London
    #1
    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
     
  2. speakerwizard thread starter macrumors 68000

    speakerwizard

    Joined:
    Aug 8, 2006
    Location:
    London
    #2
    hhmm, no, tried it with img3 and 4 to see if it conflicted but still no rollover once i add the second one in.
     
  3. slooksterPSV macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #3
    PHP:
    <script language="javascript">
    function 
    switchLogo()
    {
    if(
    == 0)
    {
     
    img1.src "logo1.png"
     
    1
    }else if(== 1)
    {
     
    img1.src "logo2.png"
     
    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
     

Share This Page