473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Rollover switch to transparent back in FF&NS

Hi,

I'm having a hard time trying to find out why the following lines don't
work in Firefox and Netscape. The idea is to change the colour of a
table row at onmouseover, and then put it back to the <body>'s original
background-image at onmouseout.

<html>

<head>
<script language="javascript">
function omo(it)
{ it.bgColor='#FFFFCC'; }
function omout(it)
{ it.bgColor='transparent'; }
</script>
</head>

<body background="http://www.google.com/images/hp0.gif">
<table border="1">
<tr onmouseover="omo(this)"
onmouseout="omout(this)">
<td class="c1">sometext</td>
<td class="c2">moretext</td>
</tr>
</table>
</body>

</html>

Obviously, the actual javascript works fine in all browsers. It's only
the assignment of

it.bgColor='transparent';

that results in a blue background in NS/FF. In IE6 it works fine.

Any workarounds ?

Thanks,

--
Bart

Jul 23 '05 #1
2 3516


Bart Van der Donck wrote:
function omo(it)
{ it.bgColor='#FFFFCC'; } if (it && it.style) {
it.style.backgroundColor = '#FFFFCC';
}
function omout(it)
{ it.bgColor='transparent'; }


if (it && it.style) {
it.style.backgroundColor = '';
}
should do.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Bart Van der Donck wrote:
Obviously, the actual javascript works fine in all browsers. It's only
the assignment of

it.bgColor='transparent';

that results in a blue background in NS/FF. In IE6 it works fine.

Any workarounds ?

The bgColor attribute is deprecated, you should set the style instead:

<html>

<head>
<script language="javascript">
function omo(it)
{ it.style.backgroundColor ='#FFFFCC'; }
function omout(it)
{ it.style.backgroundColor = 'transparent'; }
</script>
</head>

<body background="http://www.google.com/images/hp0.gif">
<table border="1">
<tr onmouseover="omo(this)"
onmouseout="omout(this)">
<td class="c1">sometext</td>
<td class="c2">moretext</td>
</tr>
</table>
</body>

</html>

will do what you want.

A better technique might be to use css with ':hover' selectors and a
behaviour file so that Internet Explorer handles them correctly. See
http://www.xs4all.nl/~peterned/csshover.html for one example of this. Using
that code your page becomes:

<html>
<head>
<style>
body { behavior:url(csshover.htc); }

tr.activerow { background-color: transparent; }
tr.activerow:hover { background-color: #FFC; }
</style>
</head>

<body background="http://www.google.com/images/hp0.gif">
<table border="1">
<tr class="activerow">
<td class="c1">sometext</td>
<td class="c2">moretext</td>
</tr>
</table>
</body>

</html>

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Mike | last post by:
Does anyone know of a minimal/mini/tiny/small xml parser in c? I'm looking for something small that accepts a stream or string, builds a c structure, and then returns an opaque pointer to that...
4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
4
by: barney | last post by:
Hello, I' m using .NET System.Xml.XmlDOcument. When I do the following: XmlDocument xml = new XmlDocument(); xml.Load("blah"); .... xml.Save("blub"); I've got the problem that the following...
7
by: Paul Lautman | last post by:
Hi y'all, I found the toggle function (shown below) and applied it to a form of mine. It works fine in IE, but in Firefox it appears to fail on the eval lines. I've searched around but I can't...
28
by: entfred | last post by:
I have the following line of html: &nbsp;&nbsp1234&nbsp;&nbsp;&nbsp;&nbsp;&nbspabc&nbsp;&nbsp;&nbspyow In Internet Explorer 6.0, the columns look ok using the above html: 1234 abcd ...
4
by: arnuld | last post by:
as i said, i have restarted the book because i overlooked some material. i want to have some comments/views on this solution. it runs fine, BTW. ------------------ PROGRAMME -------------- /*...
1
by: judacris | last post by:
I've seen the threads here about molding 2 divs in a centered fashion. but I can't seem to solve this thing. my blogger blog is functioning well on my site for now, but the blog feed (left) and...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.