去掉点击链接时周围的虚线框outline属性 dodo

1. CSS方式
在IE下是使用html属性:hideFoucs,在HTML标签中加上hidefocus=”true” 属性即可,但这个属性是IE私有的,Firefox是不认的。

<a href="#" hidefocus="true" title="加了hidefocus" >加了hidefocus属性</a>

IE中用CSS处理的方式为:

a{noOutline:expression(this.onFocus=this.blur());}/* "onFocus" 注意大小写*/


Firefox的处理方法比较符合标准,只需要在样式里设置a:focus{outline:none}皆可:

a:focus{outline:none}

MSIE和FF中的统一处理方法:

a{

outline:none; /*FF*/

noOutline:expression(this.onFocus=this.blur()); /*IE*/

}

考虑性能优化:

a{outline:none;}

a:active{noOutline:expression(this.onFocus=this.blur());}

:focus{outline:0;}

2. js方式

$("a").bind("focus", function(){

if(this.blur){

this.blur();

}

});

原文地址:https://www.cnblogs.com/zgqys1980/p/2697136.html