一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

jQuery 1.9.1丢弃的功能($.browser,scrollTop,scrollLeft)

时间:2014-01-15 编辑:简简单单 来源:一聚教程网

jQuery1.9.1有不再支持了,scrollTop 和 scrollLeft 方法了。

个人还是觉得这次更新有点太“激进”,都不向后兼容一下。而且这次还没有像browsers在API中指出替代的方法。

现在的办法就只有把原来的元素设置为relative;然后animate{"left":val,"top":val}要滚动的内容了。


没有了 $.browser 转而使用 $.support


现在希望大家使用 feature detection,不过个人感觉 jQuery 做得有点太激进了,都不向后兼容了。以前使用 $.browser 探测浏览器的程序,现在运行时都会出错了。我这里把以前的 $.browser 的代码还是找到贴出来,方便需要使用浏览器探测的朋友使用吧:

 代码如下 复制代码

(function($) {
    var a, b;
    $.uaMatch = function(a) {
        a = a.toLowerCase();
        var b = /(chrome)[ /]([w.]+)/.exec(a) || /(webkit)[ /]([w.]+)/.exec(a) || /(opera)(?:.*version|)[ /]([w.]+)/.exec(a) || /(msie) ([w.]+)/.exec(a) || a.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([w.]+)|)/.exec(a) || [];
        return {
            browser: b[1] || "",
            version: b[2] || "0"
        }
    },
    a = $.uaMatch(navigator.userAgent),
    b = {},
    a.browser && (b[a.browser] = !0, b.version = a.version),
    b.chrome ? b.webkit = !0 : b.webkit && (b.safari = !0),
    $.browser = b,
    $.sub = function() {
        function a(b, c) {
            return new a.fn.init(b, c)
        }
        $.extend(!0, a, this),
        a.superclass = this,
        a.fn = a.prototype = this(),
        a.fn.constructor = a,
        a.sub = this.sub,
        a.fn.init = function c(c, d) {
            return d && d instanceof p && !(d instanceof a) && (d = a(d)),
            $.fn.init.call(this, c, d, b)
        },
        a.fn.init.prototype = a.fn;
        var b = a(e);
        return a
   };
})(jQuery);

热门栏目