焦点问题onfocus=”this.blur()”代替方法(转)

为了去除链接的虚线框,网上搜索到最常见的方法是onfocus=“this.blur()”,不过同时搜索到的是这会不利于盲人浏览使用页面

在淘宝ued官方博客上详细说明了解决方法,这里转了部分,完整版:http://ued.taobao.com/blog/?p=3845(博客园可以放外链吗?)

去除虚线框的方法 优劣 兼容性 是否中断tab
<a href=”#” onfocus=”this.blur()”>this blur</a> 链接聚焦触发时失去焦点,js和html耦合在一起 没有兼容性问题
a:focus {outline:none}或
a{outline:none}
outline由css2.1引入,去除虚线框视觉上的问题正是css的职责 ie6/ie7不支持,ie8+/ff /safari/opera[2]支持
<a href=”#” hidefocus=”true” >hidefocus</a> 该属性是ie的私有属性[3] ie5+支持
a { noFocusLine: expression(this.onFocus = this.blur())} 可批量处理,但expression的性能问题不能忽视 expression ie6/7支持,ie8+、非ie不支持

综合以上,去除链接虚线框的推荐方法是:ie下用hidefocus属性,ff/chorme/opera/safari下用outline:none。即:

<a href=”#” hidefocus=”true” >链接</a>
a:focus {
    outline:none;
}

 模版世界:http://www.templatesy.com

 

原文地址:https://www.cnblogs.com/w2xh/p/3579672.html