Rollover on images Not working?

Discussion in 'HTML & Website Design' started by tptnyc, Jun 13, 2011.

  1. #1
    <a href="pages.html" ONMOUSEOVER=rollover.src="rollover.JPG" ONMOUSEOUT=rollover.src="images/style_one.JPG"><CENTER><IMG SRC="images/style_two.JPG" NAME="rollover"></CENTER></a>
     
    tptnyc, Jun 13, 2011 IP
  2. tsquez

    tsquez Peon

    Messages:
    77
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just a quick question: why are you not using css to handle your rollovers?

    I think that maybe it isnt working because you dont have the first part pointed to the images folder but the others are...not sure as i do not do rollovers this way.
     
    tsquez, Jun 13, 2011 IP
  3. tptnyc

    tptnyc Peon

    Messages:
    764
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Not good at css, but what should be css coding here and let me try for multiple images. Appreciate!
     
    tptnyc, Jun 13, 2011 IP
  4. karthimx

    karthimx Prominent Member

    Messages:
    4,959
    Likes Received:
    127
    Best Answers:
    2
    Trophy Points:
    340
    #4
    <A href="index.html" onMouseOver="changeImg('imgHome',gifHome2)"
    onMouseOut="changeImg('imgHome',gifHome)">
    <IMG src="home.gif" border="0" name="imgHome">
    </A>

    <SCRIPT language="javascript1.1">
    gifHome = new Image(54,18)
    gifHome.src = "home.gif"
    gifHome2 = new Image(54,18)
    gifHome2.src = "home2.gif"

    function changeImg(cImg,ref) {
    document.images[cImg].src = ref.src
    }
    </SCRIPT>
     
    karthimx, Jun 13, 2011 IP
  5. tptnyc

    tptnyc Peon

    Messages:
    764
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    karthimx:

    It's not yet clear to me. This is how I have done it, not working. (Total 5 images to rollover)

    <SCRIPT language="javascript1.1">
    JPGHome = new Image(54,18)
    JPGHome.src = "home.JPG"
    JPGHome5 = new Image(54,18)
    JPGHome5.src = "home5.JPG"

    function changeImg(cImg,ref) {
    document.images[cImg].src = ref.src
    }
    </SCRIPT>


    <A href="index.html" onMouseOver="changeImg('imgHome',JPGHome2)"
    onMouseOut="changeImg('imgHome',JPGHome)">
    <IMG src="images/style_one.JPG" border="0" name="imgHome1">
    <IMG src="images/style_two.JPG" border="0" name="imgHome2">
    <IMG src="images/style_three.JPG" border="0" name="imgHome3">
    <IMG src="images/style_four.JPG" border="0" name="imgHome4">
    <IMG src="images/style_five.JPG" border="0" name="imgHome5">
    </A>
     
    tptnyc, Jun 13, 2011 IP
  6. Guru_101

    Guru_101 Member

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    Example of a rollover effect in navigation:

    Html Code:
    
    			<div id="navi">
    				<ul>
    					<li><a href="#" id="home" class="btn" title="Home"></a></li>
    
    					<li><a href="#" id="service" class="btn" title="service"></a></li>
    					<li><a href="#" id="products" class="btn" title="products"></a></li>
    					<li><a href="#" id="contact" class="btn" title="Contact Us"></a></li>
    				</ul>
    			</div>
    
    Code (markup):
    The CSS Code

    
       #navi {
      background-image :url("images/navigation_background.png");
      float : left;
      height : 139px;
      margin : 7px 0px 0px 11px;
      width : 929px;
    }
    
     #navi ul {
      height :108px;
      margin : 13px 4px 6px -39px;
    }
    
     #navi li {
      display : block;
      float :left;
      height :108px;
      width :25%;
    }
    
     #navi .btn {
      background-position :center center;
      background-repeat :no-repeat;
      display :block;
      height :100%;
      margin :0 auto;
    }
    
     #home {
      background : url("images/btn_home_current.png");
      height : 108px;
      width : 197px;
    }
    
     #service {
      background : url("images/btn_services_normal.png");
      height : 108px;
      width : 197px;
    }
    
     #service:hover {
      background : url("images/btn_service_hover.png");
      height : 108px;
      width : 197px;
    }
    
     #products {
      background : url("images/btn_product_normal.png");
      height : 108px;
      width : 197px;
    }
    
     #products:hover {
      background : url("images/btn_products_hover.png");
      height : 108px;
      width : 197px;
    }
    
     #contact {
      background : url("images/btn_contact_us_default.png");
      height : 108px;
      width : 197px;
    }
    
     #contact:hover {
      background : url("images/btn_contact_us_hover.png");
      height : 108px;
      width : 197px;
    }
    
    
    Code (markup):
     
    Guru_101, Jun 13, 2011 IP
  7. tptnyc

    tptnyc Peon

    Messages:
    764
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    css/html coding means I have to create 20-30 url pages for each image to show as <a href="#".
    I guess java script/html suggested by karthimx above seems more plausible. I inserted my own images posted by Karthimx but i am not sure where is the error now.
     
    tptnyc, Jun 13, 2011 IP
  8. allwebactivities

    allwebactivities Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0