在FireFox中按下CTRL +鼠标单击时-<a href="javascript:userFunction();">查看</a>存在问题

在View的FireFox中按下CTRL +鼠标单击时-FireFox将打开一个新标签,其网址为“ javascript:userFunction();”

这是我的解决方法:

var FF = (navigator.userAgent.toLowerCase().indexOf('firefox') > -1);

$(function ()
{
    if( FF )
    {
        var anchors = document.getElementsByTagName('a');

        if (typeof anchors !== 'undefined' && anchors)
            for (var i = 0; i < anchors.length; i++)
            {
                if (typeof anchors[i] !== 'undefined' && !anchors[i])
                    continue;

                var h = anchors[i].getattribute("href");
                if (h)
                {
                    if (h.indexOf("javascript:") >= 0)
                    {
                        anchors[i].setattribute("onclick",h + "; return false;" );
                        anchors[i].setattribute("href","#" );
                    }
                }
            }
     }
});

有更好的解决方案吗? 谢谢。

hank112 回答:在FireFox中按下CTRL +鼠标单击时-<a href="javascript:userFunction();">查看</a>存在问题

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3040652.html

大家都在问