Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get CSS Class's in TD tags to work in Netscape

Status
Not open for further replies.

golding100

Technical User
May 24, 2001
6
GB
To date I have had the luxury of designing for IE5 only (Intranet), now I have to do the Company website as well, can anyone give me some pointers on how to get the following code to work in Netscape as well as IE5 ? Is it possible to change the CSS class of a table cell as you can with IE5 or do I have to go about the whole thing differently, if so, how?
Code:
function msover() {
if (window.event.srcElement.className == "MM") {
	window.event.srcElement.className = "MO";
	}
}
function msoff() {
if (window.event.srcElement.className == "MO") {
	window.event.srcElement.className = "MM";
	}
}
document.onmouseover = msover;
document.onmouseout = msoff;
<HTML> etc etc...............
<TD WIDTH=&quot;73&quot; HEIGHT=&quot;18&quot; Class=&quot;MM&quot; ALIGN=&quot;center&quot;>About Us</TD>
 
Older version of NN (i.e. 4.7 at least) don't seem to understand classes on a table cell. The way around that is to use a <span class=&quot;...&quot;> </span> INSIDE the table cell. HOWEVER, NN also seems to have a problem with dynamically changing attributes of some things, so that may not work either, but it's worth a try.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
In netscape 4.x, all you need is a <div> tag inside your table cell:

<td><div class&quot;className&quot;>HTML here</div></td>

Netscape generally doesn't have a problem with dynamically changing div attributes, unless you try to dynamically add positional (left, height, width, etc...) attributes to a non-positioned div. (It's almost as if Netscape has two types of <div>s, those with position: absolute/relative attributes, and those with only the simpler attributes, such as font, color, background, etc...)

Hopefully we will soon be seeing the end of the 4.x series as people move to Netscape 6, IE, or other modern browsers, and we will be able to write W3C DOM-compliant HTML.
 
hi guyz
marcus1865,
tsdragon is right, dont kno why doesnt it work for ya, may be its 'coz u arent settin position of that span?
<style>
<!--
.aaa{
position:relative;
layer-background-color: #0033CC;}
-->
</style>

<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot;>
<tr>
<td ><span class=&quot;aaa&quot;>class in nn4.61</span></td></tr>
</table>


works for me in nn4.61

regards, vic
 
I use spans without positioning inside table cells, and they still work in NN4.7. Don't know why there might be a problem. It may depend on what attributes you are trying to affect with the class.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thanks for all the comments guys, what I was trying to do was change the backgroundcolor of the <TD> on a mouseover in a way that works on Netscape and IE, so I don't think the <DIV> and <SPAN> ideas are the right way to go are they? Maybe I am going about this all wrong. Any pointers would be greatly appreciated.
 
hi
no, i'm afraid of that for nn4x spans solution is da only way 2 go..

regards, vic
 
Vituz,
Sorry to be so dim, R U saying I can do the background of a <TD> with <span>s or <div>s or that I can't and the closest I will get is to use the <span> or <div> on the text in the <TD>
 
i'm sayn that u're able of changin background color usin spans or divs, but the better way - 2 combain this 2 ways:
for ie use <td class=&quot;urClass&quot;> (btw, i think, it have 2 work in nn6 too) & for nn4x use layers, but my recomendation for ya - use <ilayer> tag, but not <span> or <div>

regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top