js 通过jquery插件获取url参数 其中的一个小问题,或许不算Bug。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/admans/article/details/6763993

 形如:http://localhost:10864/srch.htm?keys=&type=1 这样的地址,如果我们要取keys的参数:

var srchKey = $.query.get("keys");

那么得到的将是‘true’ ,而不是空客串,这常常不是我们想要的 。

修正办法如下:在jQuery.query.js文件中找到下面代码

            get: function (key)
            {
                var target = this.GET(key);
                if (typeof (target) == 'boolean')
                    return '';

                if (is(target, Object))
                    return jQuery.extend(true, {}, target);
                else if (is(target, Array))
                    return target.slice(0);
                return target;
            },

加入红色代码即可,不用再做解释。

猜你喜欢

转载自blog.csdn.net/admans/article/details/6763993