js加入收藏夹代码(包容ie/ff/op)

来源:http://www.sh-fengwen.com 作者:瘦身美容 人气:153 发布时间:2019-09-02
摘要:复制代码 代码如下: var www_jb51_net = function (obj, url, title) {     var e = window.event || arguments.callee.caller.arguments[0];     var B = {         IE : /MSIE/.test(window.navigator.userAgent) !window.opera    

复制代码 代码如下:

var www_jb51_net = function (obj, url, title) {
    var e = window.event || arguments.callee.caller.arguments[0];
    var B = {
        IE : /MSIE/.test(window.navigator.userAgent) && !window.opera
        , FF : /Firefox/.test(window.navigator.userAgent)
        , OP : !!window.opera
    };
    obj.onmousedown = null;
    if (B.IE) {
        obj.attachEvent("onmouseup", function () {
            try {
                window.external.AddFavorite(url, title);
                window.event.returnValue = false;
            } catch (exp) {}
        });
    } else {
        if (B.FF || obj.nodeName.toLowerCase() == "a") {
            obj.setAttribute("rel", "sidebar"), obj.title = title, obj.href = url;
        } else if (B.OP) {
            var a = document.createElement("a");
            a.rel = "sidebar", a.title = title, a.href = url;
            obj.parentNode.insertBefore(a, obj);
            a.appendChild(obj);
            a = null;
        }
    }
};
<a href="javascript:void(0);return false;" onMouseDown="www_jb51_net(this, '', '脚本之家是国内专业的网站建设资源、脚本编程学习类网站')">收藏脚本之家</a>

代码如下: var www_jb51_net = function (obj, url, title) { var e = window.event || arguments.callee.caller.arguments[0]; var B = { IE : /MSIE/.test(window.navigator...

本文由美高梅游戏平台网站发布于瘦身美容,转载请注明出处:js加入收藏夹代码(包容ie/ff/op)

关键词:

频道精选

最火资讯