Results 1 to 4 of 4

Thread: How to create Image Rollovers in HTML

  1. #1
    Join Date
    Mar 2009
    Posts
    42

    How to create Image Rollovers in HTML

    I am building a website in HTML & suddenly i realized that i have forgotten the code of creating the image rollover & i badly need this. As i have to make this site live by this month with the final version of the site.

    Its Urgent Please Help!

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: How to create Image Rollovers in HTML

    Here the image is doing most of your work with it. Just you have to edit & put the path which is told to give at their respective places.

    var rollOverArr=new Array();
    function setrollover(OverImgSrc,pageImageName)
    {
    if (! document.images)return;
    if (pageImageName == null)
    pageImageName = document.images[document.images.length-1].name;
    rollOverArr[pageImageName]=new Object;
    rollOverArr[pageImageName].overImg = new Image;
    rollOverArr[pageImageName].overImg.src=OverImgSrc;
    }

    function rollover(pageImageName)
    {
    if (! document.images)return;
    if (! rollOverArr[pageImageName])return;
    if (! rollOverArr[pageImageName].outImg)
    {
    rollOverArr[pageImageName].outImg = new Image;
    rollOverArr[pageImageName].outImg.src = document.images[pageImageName].src;
    }
    document.images[pageImageName].src=rollOverArr[pageImageName].overImg.src;
    }

    function rollout(pageImageName)
    {
    if (! document.images)return;
    if (! rollOverArr[pageImageName])return;
    document.images[pageImageName].src=rollOverArr[pageImageName].outImg.src;
    }
    Hope This Might have Help You....!

  3. #3
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to create Image Rollovers in HTML

    Image Rollover effect is created by java script which actually looks like this :

    <a href="index.html"
    onmouseover="buttondown('homebutton')"
    onmouseout="buttonup('homebutton')">
    <img src="homebutton.gif" name="homebutton" border="0" />
    </a>
    In this Code when the mouse mouse comes on the image the function buttondown() will perform its action & when the mouse the mouse moves away from the image then the function button down will perform its action.

    But now your web page need to call the JavaScript function. So copy the following script to the HTML Source in between <head>....</head>.


    if (document.images) {
    homebuttonup = new Image();
    homebuttonup.src = "homebutton.gif" ;
    homebuttondown = new Image() ;
    homebuttondown.src = "homebuttondown.gif" ;
    }
    function buttondown( buttonname )
    {
    if (document.images) {
    document[ buttonname ].src = eval( buttonname + "down.src" );
    }
    }
    function buttonup ( buttonname )
    {
    if (document.images) {
    document[ buttonname ].src = eval( buttonname + "up.src" );
    }
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: How to create Image Rollovers in HTML

    Rollover Buttons with pure CSS.

    You just need to create menu using the following code :

    <div class="rollover">

    <a href="#">Home</a>
    <a href="#">Gallery</a>
    <a href="#">TechArena</a>
    <a href="#">Forums</a>
    <a href="#">Exit</a>
    </div>
    You then need to make button in vertical manner in the way you want to see on page then on rollover & then on Hit.

    After creating the images. Now you have to tie all the links in CSS 2.

    .rollover a {
    display:block;
    width: 90px;
    padding:10px 10px 10px 7px;
    font: bold 13px sans-serif;;
    color:#333;
    background: url("rollover-image.gif") 0 0 no-repeat;
    text-decoration: none;
    }
    .rollover a:hover {
    background-position: 0 -35px;
    color: #049;
    }
    .rollover a:active {
    background-position: 0 -70px;
    color:#fff;
    }

Similar Threads

  1. html program to create image flip
    By Jalabala in forum Software Development
    Replies: 3
    Last Post: 19-11-2009, 01:38 PM
  2. How to put text beside an image in HTML
    By KADRI in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 09:35 PM
  3. How to resize image in html firefox ?
    By CHARO in forum Windows Software
    Replies: 4
    Last Post: 30-06-2009, 09:02 PM
  4. How to Embed Image in HTML
    By ricardoramey in forum Software Development
    Replies: 5
    Last Post: 28-06-2009, 08:11 PM
  5. How do I insert an image in HTML?
    By Pikachoo in forum Software Development
    Replies: 3
    Last Post: 05-02-2009, 11:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,510,023.43111 seconds with 16 queries