IE去掉链接虚线框的几个方法

虚线框简直就是个多余的东西,上一篇教大家怎么去除Firefox中链接和按钮虚线框,今天叫大家去掉去除IE中链接的虚线框。
方法一:利用javascript的onfocus事件,实现如下:
Html代码

<a href="http://www.hujuntao.com/" onfocus="this.blur();">设计蜂巢</a>

如果引入了jQuery框架则可以利用它的事件绑定机制:

Js代码

$('a').bind('focus', function(){   
    if(this.blur){ //如果支持 this.blur   
        this.blur();   
    }   
});

方法二:利用css样式,实现如下:

Css代码  
a{  
    blr: expression(this.onFocus=this.close());  
} /* 只支持IE,过多使用效率低 */  
a{  
    blr: expression(this.onFocus=this.blur());  
} /* 只支持IE,过多使用效率低 */  
a:focus {   
    -moz-outline-style: none;   
} /* IE不支持 */  
:focus {   
    outline: none;   
} /* for Firefox */

方法三:利用标签属性,仅支持IE,实现如下:

Html代码

<a href="http://www.hujuntao.com/" hidefocus="true">设计蜂巢</a>

方法四:HTC 实现如下:
将一下代码保存为.htc后缀的文件

Js代码

<public:attach event="onfocus" onevent="quit()" />   
<script language="javascript">   
    function quit(){   
        this.blur();   
    }   
</script>

CSS代码

a {behavior:url("htc文件")}
posted @ 2013-10-07 19:11  {前端开发}  阅读(427)  评论(0编辑  收藏  举报