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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chg TD BG on MouseOver in Netscape 1

Status
Not open for further replies.

Rick7

IS-IT--Management
Apr 15, 2003
16
US
I am using a mouseover event in a cell(TD) to change the bg color. Works in IE but not in NS. I included the JS. What am I doing wrong???

Thanks for your help!

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Hiding JavaScript -
// Generic Browser test:
var tName = navigator.appName;
var tVer = parseInt(navigator.appVersion);
var NS4 = (tName == &quot;Netscape&quot; && tVer >= 4);
var IE4 = (tName == &quot;Microsoft Internet Explorer&quot; && bVer >= 4);

function ChgColor (id,inpColor){
if (!inpColor) { inpColor = 'cc9900' };
if (NS4) {
eval ('window.document.' + id + '.bgColor = \'' + '#' + inpColor + '\'');
} else if (IE4) {
eval (id + '.style.background = \'' + '#' + inpColor + '\'');
}
}
function RetColor (id){
if (NS4) {
eval ('window.document.'+ id + '.bgColor = null');
} else if (IE4) {
eval (id + '.style.background = \'\'');
}
}
// - End -->
</SCRIPT>
 
its so much easier to do this

put this in the <td> tag

onmouseover=&quot;this.style.background='#444444'&quot; onmouseout=&quot;this.style.background='#original color'&quot;

or if you want to keep your funciton you might want to add a '#' before the hex code for the color

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
I came to a similar conclusion. Simpler is better.

Thanks.
 
lol...and it didnt even help you

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top