Solved

onfocus event for anchor <a> tag

Posted on 2003-10-21
7
1,958 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Expert Comment

by:p_partha
ID: 9590712

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
ID: 9590786
yes .... but for key board navigation
0
 
LVL 16

Accepted Solution

by:
jaysolomon earned 150 total points
ID: 9595888
have you tried

<a href="blah" onfocus="this.style.color='blue'>test</a>
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Expert Comment

by:magallanl
ID: 9595905
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
ID: 9596304
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
ID: 9596505
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
ID: 9596927
thank you very much jaysolomon, makc and magallanl
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

695 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