By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

onfocus event for hyperlinks

P: n/a
Hi,

I'm developing a website where a visistor does not have to use the mouse.
All he has to do is use the Tab-key or key-combinations to jump to specific
hyperlinks (containing accesskeys).
Next, he presses the Enter key to follow the hyperlink.

My question is: is it possible to change color of the hyperlink when a
hyperlink get the focus.
I do not only want to see the dotted line, I want the hyperlink to lighten
up.

I hope you understand what I mean.

Any help is greatly appreciated.
Sybolt
Oct 8 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
sybmathics wrote:
My question is: is it possible to change color of the hyperlink when a
hyperlink get the focus.


a:link:focus {
color: #aaaaaa;
}

a:visited:focus {
color: #aaaa00;
}

.... requires a CSS 2 browser.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 8 '05 #2

P: n/a

"David Dorward" <do*****@yahoo.com> wrote >

a:link:focus {
color: #aaaaaa;
}

a:visited:focus {
color: #aaaa00;
}

... requires a CSS 2 browser.

Does not seem to be working, David.
Should the hyperlinks be in a form?

Sybolt
Oct 8 '05 #3

P: n/a
sybmathics wrote:
... requires a CSS 2 browser.
Does not seem to be working, David.
Works perfectly here.
http://dorward.me.uk/tmp/link.png

Are you using a CSS 2 browser?
Should the hyperlinks be in a form?


Irrelevant (unless you have another selector of higher specifity involving
said form overriding the CSS I suggested)

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 8 '05 #4

P: n/a

"David Dorward" <do*****@yahoo.com> wrote in message
news:di*******************@news.demon.co.uk...

Are you using a CSS 2 browser?


the latest Maxthon and IE 6
Oct 9 '05 #5

P: n/a

"David Dorward" <do*****@yahoo.com> wrote in message
news:di*******************@news.demon.co.uk...

Works perfectly here.
http://dorward.me.uk/tmp/link.png


could you also create png of the source?
Oct 9 '05 #6

P: n/a
sybmathics wrote:
Are you using a CSS 2 browser?
the latest Maxthon and IE 6


Maxthon is, IIRC, a wrapper about the IE 6 rendering engine.

IE 6 is not a CSS 2 browser.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 9 '05 #7

P: n/a
sybmathics wrote:
http://dorward.me.uk/tmp/link.png
could you also create png of the source?


The URL to the source is visible in the image.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 9 '05 #8

P: n/a

"David Dorward" <do*****@yahoo.com>

The URL to the source is visible in the image.


OK David,

I got the message.

It would be a nice idea to show people where they are on the site by
lightening up the hyperlink.
But I guess it's just too soon.

What percentage of surfers use css2 browsers? Do you have any idea?

Could there be another way of showing (beside the dotted line around the
hyperlink) people where they are, when they are using a css1 browser? Maybe,
by using Javascript?
But, you know, I really don't like that language.

g\Greets,

Sybolt
Oct 11 '05 #9

P: n/a
sybmathics wrote:
What percentage of surfers use css2 browsers? Do you have any idea?
Its pretty much every current graphical browser except IE. The proportion of
users varies from site to site.

I hear IE7 will include support for CSS 2 selectors, so it might start
working there.
Could there be another way of showing (beside the dotted line around the
hyperlink) people where they are, when they are using a css1 browser?
Maybe, by using Javascript?
You could simulate it with the onfocus and onblur event handlers, setting
this.className or this.style.backgroundColor. There are probably packages
out there (the badly named IE7 JavaScript for example) that can process the
stylesheet and simulate support for the :focus pseudo-class.
But, you know, I really don't like that language.


This really is the right place to announce that!

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 11 '05 #10

P: n/a
> "sybmathics" <s.********@hccnet.nl> wrote:
news:43*********************@reader10.nntp.hccnet. nl....

"David Dorward" <do*****@yahoo.com>

Could there be another way of showing (beside the dotted line around
the hyperlink) people where they are, when they are using a css1
browser?


<style>
a:active{
background-color: lime;
}
a:focus{
background-color: lime;
}
</style>

--
BootNic Wednesday, October 12, 2005 8:21 AM

I try to take one day at a time, but sometimes several days attack me at once.
*Jennifer Unlimited*
Oct 12 '05 #11

P: n/a
BootNic wrote:
<style>
a:active{
background-color: lime;
}
a:focus{
background-color: lime;
}
</style>


No.

<OT>

1. The `type' attribute and value are missing for the `style' element:
<http://validator.w3.org/>

2. This affects all `a' elements, not only links.
Use a:link (and a:visited) instead.

3. Always specify background *and* foreground color:
<http://www.w3.org/QA/Tips/color>

</OT>
PointedEars
Oct 16 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.