Solved

onfocus event for anchor <a> tag

Posted on 2003-10-21
7
1,864 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

856 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