Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Background color for MouseOver

0 views
Skip to first unread message

Susan K Goben

unread,
Oct 25, 2002, 7:44:14 PM10/25/02
to
Trying to get the following script to work. The background color will only
change if I have no background color set through the CSS properties. I want
the background to change based upon which hyperlink the mouse is placed
over.

Thanks in advance,

<html>
<head><title>Search Engines</title>
<style type="text/css">
body {
background-color: silver;
}
</style>
</head>
<body >
<a href="http://www.google.com" onMouseOver="document.bgColor='yellow';
"return true;">Google</A>
<a href="http://www.altavisa.com" onMouseOver="document.bgColor='green';
"return true;">AltaVista</A>
</body>
</html>


Hans Stavleu

unread,
Oct 26, 2002, 8:36:45 AM10/26/02
to
This seems to work with me:

<html>
<head><title>Search Engines</title>

<script language=vbscript>
Sub Bg(Stl)
document.all.somebody.bgcolor = Stl
End Sub
</script>

</head>
<body id=somebody bgcolor=silver>
<a href="http://www.google.com" onMouseOver='Bg "yellow" ' onMouseOut='Bg
"silver"' >Google</A>
<a href="http://www.altavisa.com" onMouseOver='Bg "green"' onMouseOut='Bg
"silver"'>AltaVista</A>
</body>
</html>


"Susan K Goben" <skg...@cccn.net> wrote in message
news:OaMXuBIfCHA.2192@tkmsftngp10...

Susan K Goben

unread,
Oct 27, 2002, 8:24:08 AM10/27/02
to
Thanks...Yes but that is using a function which I can also do with
JavaScript.

When I place the background color through the HTML tag and then do the mouse
over it works as designed...only not when I place the background color
through CSS. Just wondering if when using CSS you have to use a function
instead of just doing the mouse over?

Thanks in advance
"Hans Stavleu" <sta...@planet.nl> wrote in message
news:ape28s$7il$1...@reader13.wxs.nl...

Kyle

unread,
Oct 29, 2002, 12:48:27 PM10/29/02
to
<A HREF=#
onMouseOver="document.body.style.backgroundColor
= 'blue';" onMouseOut="document.body.style.backgroundColor
= 'red';" onClick="return false;">Change color</A>

When using Javascript to control CSS, it can only be done
on built-in elements of the DOM ( like body ) or on named
elements(i.e.

<P style="background:red" ID="redparagraph"> ) Then
style attributes are changed by taking your element
variable, redparagraph for this example, doing .style,
and then . the CSS attribute. You CANNOT set CSS
attributes in java that were not already set in the CSS.
There is your lesson for the day. For more info, look at
the DHTML tutorial on www.webmonkey.com.

Kyle

>.
>

0 new messages