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

onFocus change classname

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
hey there i am using the following code to assign a classname to an element when the element has got the focus

this is something that i have done before but for some reason this has decided not to work. I am now using IE 6 on a win xp home edition

this is the html line:

<td align=&quot;center&quot; ID=&quot;help&quot; class=&quot;dull&quot;><A HREF=&quot;help.asp&quot; tabindex=&quot;1&quot; onfocus=&quot;javascript:focusText('help');&quot;>Help</a></td>

this is the javascript call - i know this won't work in NN but not too bothered about that at the moment

function focusText(theItem) {
document.all[theItem].classname = &quot;hilite&quot;;
}

when i do an alert right after the js code it says that the classname that it is using is the hilite one ! but it is not actually changing the display on the page and the new classname is a completly different colour

any ideas would be appreciated !
 
not to worry found what the problem was !

for some reason if i put the whole if statement around the javascript is now works !

so the javascript now looks like:

function focusText(theItem) {

if (document.layers) {
//Netscape
document.elements[theItem].className='hilite';
}
else {
//IE
document.all[theItem].className='hilite';
}
}

weirdness !
 
i believe that it does there are some things in the classes that can upset NN but i believe for the most it works fine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top