C语言 c++ php mysql nginx linux lnmp lamp lanmp memcache redis 面试 笔记 ppt 设计模式 问题 远程连接

解决a标签IE下点击后出现轮廓框

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>解决a标签IE下点击后出现轮廓框</title>
<script>

function FaddEvent(e, evt, fn, isID) {
    if (isID == true)
        e = Fid(e);
    if (!Fempty(e.attachEvent) && (typeof(e.attachEvent) == "function" || typeof(e.attachEvent) == "object"))
        e.attachEvent("on" + evt, fn);
    else if (!Fempty(e.addEventListener) && (typeof(e.addEventListener) == "function" || typeof(e.addEventListener) == "object"))
        e.addEventListener(evt, fn, false);
}

function Fempty(v) {
    if (v != null && (typeof(v) == 'object' || typeof(v) == 'function'))
        return false;
    return (("" == v || undefined == v || null == v) ? true : false);
}

//解决ie下 a标签点击后出现问题
function fixoutline()
{
    var as = document.getElementsByTagName("a");

    for(var i=0,len=as.length;i<len;i++)
    {
        (function(i){
            as[i].onfocus = function(){
                this.blur();
            }
            
            as[i].hidefocus = true;
        })(i)
    }
}


FaddEvent(window,
'load',function(){ fixoutl
//动态绑定
function fixoutline()
{
    function handle(e){
        var evt = window.event ? window.event : e;

        var target = evt.target || evt.srcElement;

        if(target.tagName == 'A'){
           target.blur();
        }else if(target.tagName == 'IMG' || target.tagName == 'SPAN')
        {
            target.parentNode.blur();
        }    
    }

   //相对应的context如果没有可以用document
    
    Fid('content').onclick = handle;
}


fixoutline();

 

ine();
})

</script>
</head>

<body>
<a target="_blank" href="http://www.baiud.com">百度</a> <a target="_blank" href="http://www.baiud.com">腾讯</a> <a href="javascript:void(0);">百度</a> <a href="javascript:void(0);">腾讯</a>
</body>
</html>

 

 

 

 

效果图:

  

posted on 2013-07-02 17:58  思齐_  阅读(758)  评论(0编辑  收藏  举报