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

 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();

       }

});

 

转自E世年华的博客

原文链接:http://www.cnblogs.com/ango001/articles/2195718.html

posted @ 2012-02-22 11:19  小鱼1982  阅读(263)  评论(0编辑  收藏  举报