Maison  >  Article  >  interface Web  >  js ajoute du code aux favoris (compatible avec ie/ff/op)_compétences javascript

js ajoute du code aux favoris (compatible avec ie/ff/op)_compétences javascript

WBOY
WBOYoriginal
2016-05-16 16:47:571328parcourir

复制代码 代码如下 :

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 = titre, a.href = url;
            obj.parentNode.insertBefore(a, obj);
            a.appendChild(obj);
             a = null;
        }
}
};
收藏脚本之家

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn