当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 去除链接虚线全面分析总结

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 去除链接虚线全面分析总结


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 428 ::
收藏到网摘: n/a

传统办法,在标签内加属性 代码多,修改难
<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>
<a href="link1.htm" hidefocus>link1</a> 非标准
中级办法,全局控制 
CSS实现 增加IE负担,不推荐使用
a{blr:expression(this.onFocus=this.close());}
a{blr:expression(this.onFocus=this.blur());}
HTC实现 IE支持,并有延迟,不推荐
把下面这段代码存为.htc为扩展名的文件
<public:attach event="onfocus" onevent="hscfsy()"/>
<script language="javascript">
function hscfsy(){
this.blur();
}
< /script>
样式调用
a {behavior:url(htc文件所在路径地址)}
高级办法,全局控制
遍历实现
window.onload=function()
{
for(var ii=0; ii<document.links.length; ii++)
document.links[ii].onfocus=function(){this.blur()}
}
将其封装为一个函数
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://blog.csdn.net/alonesword/“ onFocus="this.blur()">
<Img Src="Example.jpg" Border=0>
</a>
其中,onFocus是设置鼠标焦点事件的东西,这个可以用,也可以不用,不过为了让更多的浏览器识别的话,建议采用;Border=0 这个才是去除虚线框的关键所在(在网上看到有的人用onFocus=“this.blur()“来消除虚线框,但在本地测试时,仅仅用这一句是不能消除的)