Link to home
Start Free TrialLog in
Avatar of ja_jamal
ja_jamal

asked on

onfocus event for anchor <a> tag

Hi,

We are using anchor tags in the left frame (all action items), on focusing(using tab key) to the respective link, I have to change the color. I have used onFocus event, but it is not working.

I did the same for MouseOver,  its working fine.

Can anybody help me to solve this problem.

Thanks,
jamal
Avatar of p_partha
p_partha


do u want like this?
<a href="www.test.com" onmouseover ='this.style.color="red"' onmouseout='this.style.color="blue"'>test</a>


Partha
Avatar of ja_jamal

ASKER

yes .... but for key board navigation
ASKER CERTIFIED SOLUTION
Avatar of jaysolomon
jaysolomon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi ja_jamal,

The focus event is not supported by links.  By far the elements of a form object (reset, submit, password, radio, etc), layers and window object are the ones that can receive focus event.

You could 'fake' it using layers instead, but that would not just highlight the text but the whole box of the layer.

- magallanl
try this html:
<a href=# onfocus="alert(0)">blah</a><br>
<a href=# onfocus="alert(1)">blah</a><br>
<a href=# onfocus="alert(2)">blah</a><br>

click anywhere in the page and hit TAB. you'll get box saying "0". Hit TAB again. Now it says "1"... and so on.

what's the problem, really?

<a href=# onfocus="this.style.color='red'" onblur="this.style.color='blue'">blah</a><br> gives you what you want, jaysolomon is completely right, and 1st, here...
Hi ja_jamal,

makc and jaysolomon are right. The onfocus handler does work.  My apologies, as I was testing it using Netscape and it doesn't work quite the way it does in IE.

thank you very much jaysolomon, makc and magallanl