Forum Moderators: open

Message Too Old, No Replies

CSS buttons in IE

Getting links to look appropriately in IE

         

Higamigokoru

4:41 am on Aug 26, 2003 (gmt 0)

10+ Year Member



Hi.
I just found this site the other day.
(now for the stuff you haven't read ten thousand times before)

I'm using CSS on my site to give my links a button-ish look:

a:link {color : #ADD8E6; background-color: #3399FF;}
a:visited {color : #ADD8E6; background-color: #3399FF;}
a:active {color : #D3D3D3;}
a:hover {color : #ffffff; background-color: #555555;}

Its working out nicly, except IE puts an outline around around active links. My site is in frames, and the 'butons' are meant for the nav bar. This sort of ruins the effect, IMHO.

So the question is: Is there any way to tell IE to knock it off?

msr986

4:55 am on Aug 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use the following 'onClick' javaScript to your anchor tags:

<a href=# onClick="this.blur(); return true">

This will erase the outline.

Higamigokoru

5:08 am on Aug 26, 2003 (gmt 0)

10+ Year Member



Thanks!

MonkeeSage

5:25 am on Aug 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Higamigokoru!

You can also programmatically make all your links act the same way:

 function buttonBlur() {
var lnks = document.links, i;
for (i = 0; i < lnks.length; ++i) {
lnks[i].onclick = "this.blur()"; // non-DOM2 browsers like IE
lnks[i].setAttribute("onclick", "this.blur()"); // DOM2 browser like NN7
}
}

<body onload="buttonBlur();">

Jordan

Ps. There are attributes in the CSS3 draft that will allow this behaviour to be controlled from CSS, e.g.,

outline: none none 0;
...but I doubt MS will catch up to CSS3 for a long time.