changing a background image to a background colour?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dj Frenzy

    #1

    changing a background image to a background colour?

    Hi, I know how to use javascript to change a background image to
    another background image, and how to change a background colour to
    another background colour. Is there a way to change an image to a
    backgound colour?

    I have a table with a background that has a picture. When the user
    hovers over the picture I want the background to change to the
    background colour of the rest of the page, as if to make the picture
    disappear.

    Cheers,
    Dave
  • kaeli

    #2
    Re: changing a background image to a background colour?

    In article <814d695f.04020 90614.25dde76@p osting.google.c om>, dado0583
    @hotmail.com enlightened us with...[color=blue]
    > Hi, I know how to use javascript to change a background image to
    > another background image, and how to change a background colour to
    > another background colour. Is there a way to change an image to a
    > backgound colour?
    >
    > I have a table with a background that has a picture. When the user
    > hovers over the picture I want the background to change to the
    > background colour of the rest of the page, as if to make the picture
    > disappear.
    >
    > Cheers,
    > Dave
    >[/color]

    This worked in IE6. Didn't test it in any other browsers.

    <html>
    <head>
    <title> New Document </title>
    <script type="text/javascript" language="javas cript">
    function changeIt(el,w)
    {
    if (w=="image")
    {
    el.style.backgr ound="url(warni ng.gif)";
    el.style.backgr oundColor="tran sparent";
    }
    else
    {
    el.style.backgr ound="";
    el.style.backgr oundColor="red" ;
    }
    }
    </script>
    </head>

    <body>
    <p>Hi there. This is a test.</p>
    <table border="1" cellpadding="3" id="t" onMouseOver="ch angeIt
    (this,'color')" onMouseOut="cha ngeIt(this,'ima ge')"
    background="war ning.gif">
    <tr>
    <td>test1</td>
    <td>test2</td>
    <td>test3</td>
    <td>test4</td>
    </tr>
    <tr>
    <td>test1</td>
    <td>test2</td>
    <td>test3</td>
    <td>test4</td>
    </tr>
    </table>
    </body>
    </html>

    --
    --
    ~kaeli~
    The man who fell into an upholstery machine is fully
    recovered.



    Comment

    • Robert

      #3
      Re: changing a background image to a background colour?

      You can always make up an image of any color you want and swap it as you
      would an image.

      Gif one color images are amazingly small.

      Robert

      Comment

      • Randy Webb

        #4
        Re: changing a background image to a background colour?

        Dj Frenzy wrote:
        [color=blue]
        > Hi, I know how to use javascript to change a background image to
        > another background image, and how to change a background colour to
        > another background colour. Is there a way to change an image to a
        > backgound colour?
        >
        > I have a table with a background that has a picture. When the user
        > hovers over the picture I want the background to change to the
        > background colour of the rest of the page, as if to make the picture
        > disappear.
        >[/color]

        onmouseover="ol dSource=this.sr c;this.src='tra nsparent.gif'"
        onmouseout="thi s.src=oldSource "

        transparent.gif is a 100% transparent gif. When its swapped, it gives
        the illusion of making the original "disappear" .


        --
        Randy
        Chance Favors The Prepared Mind
        comp.lang.javas cript FAQ - http://jibbering.com/faq/

        Comment

        • Robert

          #5
          Re: changing a background image to a background colour?

          Randy Webb <hikksnotathome @aol.com> wrote in message news:<qNSdnVSWA LZOVLXd4p2dnA@c omcast.com>...[color=blue]
          > Dj Frenzy wrote:
          >[color=green]
          > > Hi, I know how to use javascript to change a background image to
          > > another background image, and how to change a background colour to
          > > another background colour. Is there a way to change an image to a
          > > backgound colour?
          > >
          > > I have a table with a background that has a picture. When the user
          > > hovers over the picture I want the background to change to the
          > > background colour of the rest of the page, as if to make the picture
          > > disappear.
          > >[/color]
          >
          > onmouseover="ol dSource=this.sr c;this.src='tra nsparent.gif'"
          > onmouseout="thi s.src=oldSource "
          >
          > transparent.gif is a 100% transparent gif. When its swapped, it gives
          > the illusion of making the original "disappear" .[/color]

          Note: At least in this case, a web browser will automaticlly expand
          the size of your gif image to fit what is in the html file. This
          means a one pixel transparent image is fine.

          Robert

          Comment

          Working...