`

去除链接虚线框

阅读更多
局部控制

<a href="link1.htm" onfocus="this.blur()">link1</a>

<a href="link1.htm" onfocus="this.close()">link1</a>

<a href="link1.htm" hidefocus="true">link1</a>

<a href="link1.htm" hidefocus="hidefocus">link1</a>

全局控制 

CSS实现

a{blr:expression(this.onFocus=this.close());} /* 只支持IE,过多使用效率低 */

a{blr:expression(this.onFocus=this.blur());} /* 只支持IE,过多使用效率低 */

a:focus { -moz-outline-style: none; } /* IE不支持 */

HTC实现 IE支持,页面载完才有效果

把下面这段代码存为.htc为扩展名的文件
<public:attach event="onfocus" onevent="hscfsy()"/>
<script language="javascript">
function hscfsy(){
this.blur();
}
</script>

调用 a {behavior:url(htc文件所在路径地址)}

JS遍历实现
window.onload=function()
{
for(var ii=0; ii<document.links.length; ii++)
document.links$[$ii$]$.onfocus=function(){this.blur()}
}

JS封装为函数
function fHideFocus(tName){
aTag=document.getElementsByTagName(tName);
for(i=0;i<aTag.length;i++)aTag$[$i$]$.hideFocus=true;
//for(i=0;i<aTag.length;i++)aTag$[$i$]$.onfocus=function(){this.blur();};
}

当前是添加一个hidefocus的属性,注释掉的句子是添加onfucus=this.blur();
然后调用fHideFocus("A"),即可把a的虚线框去掉
通过传递不同的参数,可以去掉更多的虚线框,比如"BUTTON"可以去掉button的
但要记住参数要用大写字母

A. map area内链接如何消除链接虚线?

这是一个观念上的错误,其实应该在所在map的图片上加以控制,而不是在area内,参考传统办法

B. 关于onFocus
<a href=“http://www.baidu.com“ onFocus="this.blur()">
<Img Src="Example.jpg" Border=0>
</a>

onFocus是设置鼠标焦点事件的东西,这个可以用,也可以不用,不过为了让更多的浏览器识别的话,建议采用Border=0 这个才是去除虚线框的关键所在(在网上看到有的人用onFocus="this.blur()"来消除虚线框,但在本地测试时,仅仅用这一句是不能消除的)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics