473,805 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bgcolor from a 'this'

@sh
Trying to do this, but its not working...?! My aim being to change the
bgcolor of the cell upon which the user has rolled over, I'll then replicate
this as an OnMouseOut to change it back.

-----------------------------
<script language="JavaS cript">
<!--
function Ash_TopNavRollo vers(TheObject) ; {
TheObject.bgcol or="#000099;";
}
-->
</script>
-----------------------------

AND IN THE BODY...

-----------------------------
<td width="91" align="center" valign="middle" ><a href="#"
class="TopNavTe xtNormal" OnMouseover="As h_TopNavRollove rs(this);">Butt on
Text Here</a></td>
-----------------------------

Appreciate your help!
Jul 23 '05 #1
15 2470
@sh wrote:
<script language="JavaS cript">
use the
type="text/javascript"
attribute instead of the deprecated language attribute.

TheObject.bgcol or="#000099;";
use CSS instead:

TheObject.style .backgroundColo r="#000099;";

class="TopNavTe xtNormal"


Maybe this class defines it's own background-color and changing the HTML
elements bgcolor attribute doesn't have an effect though.

Daniel
Jul 23 '05 #2
@sh wrote:
Trying to do this, but its not working...?! My aim being to change the
bgcolor of the cell upon which the user has rolled over, I'll then replicate
this as an OnMouseOut to change it back.

-----------------------------
<script language="JavaS cript">
<!--
function Ash_TopNavRollo vers(TheObject) ; {
TheObject.bgcol or="#000099;";
}
-->
</script>
-----------------------------
<script type="text/javascript">
function Ash_TopNavRollo vers(theObject) {
if(theObject && theObject.style ){
theObject.style .backgroundColo r="#000099";
}
}
</script>

<style type="text/css">
a {display: block;}
</style>

Mick

AND IN THE BODY...

-----------------------------
<td width="91" align="center" valign="middle" ><a href="#"
class="TopNavTe xtNormal" OnMouseover="As h_TopNavRollove rs(this);">Butt on
Text Here</a></td>
-----------------------------

Appreciate your help!

Jul 23 '05 #3
Mick White wrote:
@sh wrote:
Trying to do this, but its not working...?! My aim being to change the
bgcolor of the cell upon which the user has rolled over, I'll then
replicate this as an OnMouseOut to change it back.

-----------------------------
<script language="JavaS cript">
<!--
function Ash_TopNavRollo vers(TheObject) ; {
TheObject.bgcol or="#000099;";
}
-->
</script>
-----------------------------


Seeing as 'A' is the *only* element that IE allows CSS 'hover' on (and
even then it must have a href attribute), why not use that? No JS
required at all.

Head:

<style type="text/css">
#special a {
display: block;
}
#special a:hover {
background-color:#000099;
}
#special td {
width: 5em;
text-align: center;
}
</style>
Body:

<table id="special">
<tr>
<td valign="middle" ><a href="#">Button Text Here</a></td>
</tr>
</table>
<a href="#">Ordina ry A</a>

--
Rob
Jul 23 '05 #4
ASM
@sh wrote:
Trying to do this, but its not working...?! My aim being to change the
bgcolor of the cell upon which the user has rolled over, I'll then replicate
this as an OnMouseOut to change it back.


http://perso.wanadoo.fr/stephane.mor...ht_rows_fr.htm
http://perso.wanadoo.fr/stephane.mor...t_cells_fr.htm
http://perso.wanadoo.fr/stephane.mor...t_cells_en.htm

I'm surprise that :

<table width=50% border=1><tr>
<td onmouseover="th is.bgColor='yel low'"
onmouseout="thi s.bgColor='skyb lue'">a1</td>
<td onmouseover="th is.bgColor='yel low'"
onmouseout="thi s.bgColor='skyb lue'">b1</td>
<td>c1</td></tr>
<tr>
<td onmouseover="th is.bgColor='#FF FFCC'"
onmouseout="thi s.bgColor='#FFC CFF'">a2</td>
<td onmouseover="th is.bgColor='#FF FFCC'"
onmouseout="thi s.bgColor='#FFC CFF'">
b2</td><td>c2</td></tr></table>

don't work for you

(you did notice it is bgColor and not bgcolor )

My Opera won't accept colors like '#FFF' or '#fff'
--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #5
RobG wrote:
Mick White wrote:
@sh wrote:
Trying to do this, but its not working...?! My aim being to change
the bgcolor of the cell upon which the user has rolled over, I'll
then replicate this as an OnMouseOut to change it back.

-----------------------------
<script language="JavaS cript">
<!--
function Ash_TopNavRollo vers(TheObject) ; {
TheObject.bgcol or="#000099;";
}
-->
</script>
-----------------------------

Seeing as 'A' is the *only* element that IE allows CSS 'hover' on (and
even then it must have a href attribute), why not use that? No JS
required at all.


Maybe it's because nobody has answered the original question? The
question was to be able to change the background color of a table cell
that a user mouse's over. The problem lies in the fact that the A tag is
being used when it should be the TD's onmouseover/out that is being
used. If the table cell is wider than the link is, the problem becomes
very apparent :)
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #6
Randy Webb wrote:

[snip]


Maybe it's because nobody has answered the original question? The
question was to be able to change the background color of a table cell
that a user mouse's over.
The original:
"My aim being to change the bgcolor of the cell upon which the user has
rolled over, I'll then replicate this as an OnMouseOut to change it back."

Sounds like he's looking for "hover" to me.
Mick
The problem lies in the fact that the A tag is being used when it should be the TD's onmouseover/out that is being
used. If the table cell is wider than the link is, the problem becomes
very apparent :)

Jul 23 '05 #7
ASM
Mick White wrote:
Randy Webb wrote:
Maybe it's because nobody has answered the original question?


The original:
"My aim being to change the bgcolor of the cell upon which the user has
rolled over, I'll then replicate this as an OnMouseOut to change it back."

Sounds like he's looking for "hover" to me.


hover sounds like css code to me
while
onMouseOver sounds like JS to me ;-)

the right answer is :

*bgColor* and not *bgcolor*

<script language="JavaS cript"><!--
function Ash_TopNavRollo vers(TheObject) ; {
TheObject.bgCol or="#000099;";
}
function Ash_TopNavRollo uters(TheObject ); {
TheObject.bgCol or="#FFFFCC;";
}
// --></script>

<table><tr>
<td
onmouseover="As h_TopNavRollove rs(this);"
onmouseout="Ash _TopNavRolloute rs(this);"> foo </td>
<td
onmouseover="th is.bgColor='#00 0099';"
onmouseout="thi s.bgColor='#FFF FCC';"> foo </td>
</tr></table>

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #8
Mick White wrote:
Randy Webb wrote:

[snip]


Maybe it's because nobody has answered the original question? The
question was to be able to change the background color of a table cell
that a user mouse's over.

The original:
"My aim being to change the bgcolor of the cell upon which the user has
rolled over, I'll then replicate this as an OnMouseOut to change it back."

Sounds like he's looking for "hover" to me.


Yes, it does. But the problem with the approach was that the A element
was passing a reference to "this" which points at the A element and not
the TD that contains it. So technically speaking, it was changing the
background of the link and not of the TD. That works fine if the only
child of the TD is the A element, but if there is more in the TD than
the link then it becomes apparent that the A is changing colors and not
the TD.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #9
ASM
Randy Webb wrote:
But the problem with the approach was that the A element
was passing a reference to "this" which points at the A element and not
the TD that contains it.


Tremendous ! there was a link ?

so it is :

<script type="text/javascript"><!--
function rol(link){
var c = link.parentNode .bgColor;
link.parentNode .bgColor = c=='#FFFFCC'||c =='#ffffcc'?
'#FFCCFF':'#FFF FCC';
}
// --></script>

<table width=50% border=1><tr>
<td>
<a href="#" onmouseover="ro l(this)" onmouseout="rol (this)">a 1</a>
</td><td>
<a href="#" onmouseover="ro l(this)" onmouseout="rol (this)">b 1</a>
</td><td>
c 1
</td>
</tr><tr>
<td>
<A HREF="#" onmouseover="th is.parentNode.b gColor='#FFFFCC '"
onmouseout="thi s.parentNode.bg Color='#FFCCFF' ">a 2</a>
</td><td>
<a href="#" onmouseover="th is.parentNode.b gColor='#FFFFCC '"
onmouseout="thi s.parentNode.bg Color='#FFCCFF' ">b 2</A>
</td><td>
c 2
</td></tr></table>
--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #10

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

Similar topics

4
6646
by: A.S. | last post by:
Hi, I have the following simple code: <TABLE><TR> <TD BGCOLOR="#FFFFFF" ONCLICK="myform.color.value = this.bgcolor">hello</TD> </TR></TABLE> <FORM ACTION="hello.cgi" NAME="myform" ID="myform">
6
9828
by: Tim Johnson | last post by:
Hello All: Using javascript to dynamically add row elements to a table. as in ..... row.setAttribute("bgcolor",rowColor); // or cell.setAttribute("bgcolor",rowColor); Using firefox or netscape I'm seeing colors rendered as I would hope for. However the same process in Internet Explorer does render the
3
1257
by: Peter Merwood | last post by:
Hi I've developed a simple ASP.NET page using Visual Studio 2003. On the page are a number of tables which I have shaded the background of using the bgcolor table attribute/property. My HTML code to do this is shown below: TABLE id="tblAddress" style="BORDER-RIGHT: navy 0.75pt solid; BORDER-TOP: navy 0.75pt solid; Z-INDEX: 103; LEFT: 8px; BORDER-LEFT: navy 0.75pt solid; BORDER-BOTTOM: navy 0.75pt solid; POSITION: absolute; TOP: 16px"...
6
3729
by: acord | last post by:
Hi, I want to change the background color of a ul/li row, but the following code is not working as I expected. It works in <table><tr>... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
12
4555
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in another forum from Peter Huang that said that an id="bg" as follows... <body MS_POSITIONING="GridLayout" runat="server" id="bg"> then we could do the following in our codebehind file....
3
5366
Duchesse
by: Duchesse | last post by:
Hoi! Does anyone know how to make the bgcolor in HTML different than the background color of my SWF movie. I've tried playing around with the bgcolor in <body> and the bgcolor in the SWF parameters but it always ends up being the same. If anyone has any ideas it would be great. Thanks.
4
1667
by: Don Lancaster | last post by:
I set up a table... <table bgcolor=#FF9966 name=msSel onmouseover="msSel.bgColor='#FFCC66'" onmouseout="differentFunction ();" <tr><td>stuff</tr></td> mouseout is eventully supposed to do several things,
5
1845
by: Don Lancaster | last post by:
I am trying to change a group of background colors by calculating their names in a loop . Names are cfh13, cfh15, cfh17, etc... Unlooped code like cfh17.bgColor="#CCFFFF" ; works just fine. Code that does NOT involve a background color change but is calculated
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.