Solved

onfocus event for anchor <a> tag

Posted on 2003-10-21
7
1,844 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
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

806 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