A標籤虛線框去掉3種方法(CSS/JS/jquery)

來源:互聯網
上載者:User


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的處理方法比較符合標準,只需要在CSS樣式代碼裡設定a:focus

{outline:none}皆可。接下來看一下MSIE和FF中統一處理的方法:
a{
outline:none; /*FF*/
noOutline:ex
pression(this.onFocus=this.blur());/*IE*/
}

css htc檔案處理

a {behavior:url("htc檔案")}

考慮效能最佳化,可參考以下代碼:

a{outline:none;}
a:active{noOutline:expression(this.onFocus=this.blur());}
:focus{outline:0;}

2. 用js方式解決連結虛框的方法:

<script language="javascript">
$("a").bind("focus", function(){
if(this.blur){
this.blur();
}
});
</script>


利用javascript的onfocus事件,實現如下:


<a href="http://www.111cn.net/" onfocus="this.blur();">設計蜂巢</a>


JQ的寫法:

$("input:not(input[type='text'],input[type='password'])").focus(function(){
    this.blur();
});

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.