OK, I'll leave the question open for a while, but one extra thing - how can I change the text in the status bar to show the link address when the cursor is over the cell but not over the link?
Main Topics
Browse All TopicsI want to make a cell change colour when the mouse hovers over it, so I can create a "pretty" contents table. I just found this code from a site:
<tr bgcolor="#CCCCCC" bordercolor="#000000">
<th height="18" width="326"
onMouseOver="style.backgro
onMouseOut="style.backgrou
href="http://www.link.com"
</tr>
And I was wondering if there was a way to avoid having to specify the colour change for each cell, i.e use a style sheet, or something? Or maybe there is a better way of making the colour change in the first place. Any help would be appreciated. Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You could do that using the link-array
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script>
function changeStyle(obj,link)
{
obj.style.backgroundColor=
style.cursor='hand';
self.status=document.links
}
function changeStyle2(obj)
{
obj.style.backgroundColor=
self.status='';return true;
}
</script>
</head>
<body>
<table>
<tr><td>Table cell1</td><td>Table cell</td></tr>
<tr><td>Table cell3</td><td>Table cell4</td></tr>
<tr bgcolor="#CCCCCC" bordercolor="#000000">
<th height="18" width="326"
onMouseOver="changeStyle(t
onMouseOut="changeStyle2(t
href="http://www.link.com"
</tr>
</table>
</body>
</html>
the value'0' in changeStyle(this,'0'); represents the element number in the linkarray. You have to increase this number with one for each table cell. I don't know any better way to do this.
the best way is to use style sheets.
in the style block you define the style you want and in the even you define the class you want to use.
the only thing you have to change is the style properties.
<html>
<head>
<style>
.classA{
text-align : center;
background-color : Yellow;
border : medium ridge #F08080;
font-wecolor: Blue;
font-weight : bold;
}
</style>
</head>
<body>
<span id='text1' onmouseout="out(this)" onmouseover="over(this)">m
<script>
function out( obj ){ obj.className = ""; }
function over( obj ){ obj.className = "classA"; }
</script>
</body>
</html>
I have this on a site of mine here is how I did it, play around with the settings in the style sheet to change the colors and look:
<style>
.tdnav {
background: 014E20;
border-style:solid;
border-width:1px;
border-color:009933;
color:lime;
font-size: smaller;
cursor: hand;
text-align: center;
}
</style>
<table width="100%" align="center" border="0" bordercolor="red">
<tbody>
<tr width="100%">
<td class="tdnav" onmouseover="this.style.ba
onmouseout="this.style.bac
<td class="tdnav" onmouseover="this.style.ba
onmouseout="this.style.bac
<td class="tdnav" onmouseover="this.style.ba
onmouseout="this.style.bac
<td class="tdnav" onmouseover="this.style.ba
onmouseout="this.style.bac
</tr>
</tbody>
</table>
webdiva69,
Welcome to Experts-exchange. Please read the guidelines for comments and answers.
What you posted as "answer" is exactly what the questioner has said they want to avoid. In the future please read the question. The normal conduct for experts in the forum is to post comments, not answers. By "answering" the question you have lock the question out of the active list and reduce the possibility that another expert will post a solution.
I recommend that you observe how the other experts conduct themselves while you are still learning the site.
I will ask the moderators to review the question and reject your answer.
Cd&
Hello webdiva69, we here at Experts-Exchange prefer to use the Comment Button, there are reasons for this. If you will kindly read the Tips on Commnets and Answers below this box, the go to *click here* link, you will be able to read the site rules for Experts on EE.
Thanks and Welcome to EE
ComTech
Community Support Moderator
I have rejected you Proposed Answer for the reasons above.
ComTech yes 2 people have already said the same thing...
Anyway Adding it as a comment:
I have this on a site of mine here is how I did it, play around with the settings in the style sheet
to change the colors and look:
<style>
.tdnav {
background: 014E20;
border-style:solid;
border-width:1px;
border-color:009933;
color:lime;
font-size: smaller;
cursor: hand;
text-align: center;
}
</style>
<table width="100%" align="center" border="0" bordercolor="red">
<tbody>
<tr width="100%">
<td class="tdnav" onmouseover="this.style.ba
onmouseout="this.style.bac
<td class="tdnav" onmouseover="this.style.ba
onmouseout="this.style.bac
<td class="tdnav" onmouseover="this.style.ba
onmouseout="this.style.bac
<td class="tdnav" onmouseover="this.style.ba
onmouseout="this.style.bac
</tr>
</tbody>
</table>
There are some bits and pieces here, but everyone seems reluctant
to bite the bullet and do it the right way.
we11er,
It is not reasonable to expect to implement a mouseevent at a detailed
level without having to code it at the detail level. If you think
there is too much coding involved then don't do the effect. I suppose
you could script something at the body level to test for mousemove
events and then map the cursor position to the position where a cell
might be at the current resolution. Of course you would impair
performance and end up writing even more code but you might save a
line of code for each cell. Nothing is free, and nothing comes
without work.
What you can do is reduce the amount of future work for making
changes by structing things properly.
Declare both styles to be used in the head:
<style>
.overclass {background-color:blue}
.outclass {background-color:red}
</style>
then do the cells this way.
<td class="outclass"
onMouseover="this.classNam
onMouseout="this.className
The code is the same for evey cell just cut and paste. If that is
too much coding, you probably are best to avoid web development as
as carreer or hobby.
Cd&
OK, I've accepted COBOLdinosaur's comment - I know everybody posted similar solutions, but this one seemed to have everything I wanted - I can change the style of all the hover cells by modifying one stylesheet entry, rather than going through all the HTML code of the file(s), and replacing, for example, #FFFFFF with #FFFFCC.
Business Accounts
Answer for Membership
by: BatalfPosted on 2001-11-19 at 07:02:54ID: 6641826
I don't think you could specify a "rule" for event-handlers.
"#DDDDDD";
"#CCCCCC";
his);" his)" onClick="'http://www.link. com'"><a class="menu">Link</a></th>
But this could maybe make your code a little bit easier to maintain:
<head>
<script>
function changeStyle(obj)
{
obj.style.backgroundColor=
style.cursor="hand";
}
function changeStyle2(obj)
{
obj.style.backgroundColor=
}
</script>
</head>
<body>
<table>
<tr bgcolor="#CCCCCC" bordercolor="#000000">
<th height="18" width="326"
onMouseOver="changeStyle(t
onMouseOut="changeStyle2(t
href="http://www.link.com"
</tr>
</table>