Solved

onfocus event for anchor <a> tag

Posted on 2003-10-21
7
1,788 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:ja_jamal
7 Comments
 
LVL 14

Expert Comment

by:p_partha
Comment Utility

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


Partha
0
 

Author Comment

by:ja_jamal
Comment Utility
yes .... but for key board navigation
0
 
LVL 16

Accepted Solution

by:
jaysolomon earned 150 total points
Comment Utility
have you tried

<a href="blah" onfocus="this.style.color='blue'>test</a>
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Expert Comment

by:magallanl
Comment Utility
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
0
 
LVL 3

Expert Comment

by:makc
Comment Utility
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...
0
 

Expert Comment

by:magallanl
Comment Utility
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.

0
 

Author Comment

by:ja_jamal
Comment Utility
thank you very much jaysolomon, makc and magallanl
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now