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

来源:互联网 发布:死亡录像知乎 编辑:程序博客网 时间:2024/04/28 03:31

转载自:http://www.hujuntao.com/archives/ie-remove-the-link-to-the-dotted-rectangle-several-ways.html

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

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

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

Js代码

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

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

  1. Css代码
  2. a{
  3. blr: expression(this.onFocus=this.close());
  4. } /* 只支持IE,过多使用效率低 */
  5. a{
  6. blr: expression(this.onFocus=this.blur());
  7. } /* 只支持IE,过多使用效率低 */
  8. a:focus {
  9. -moz-outline-style: none;
  10. } /* IE不支持 */
  11. :focus {
  12. outline: none;
  13. } /* for Firefox */

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

Html代码

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

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

Js代码

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

CSS代码

  1. a {behavior:url("htc文件")}