function getQueryObject(url) {

    url = url == null ? window.location.href : url;
    var search = url.substring(url.lastIndexOf("?") + 1);
    var obj = {};
    var reg = /([^?&=]+)=([^?&=]*)/g;
    search.replace(reg, function (rs, $1, $2) {
        var name = decodeURIComponent($1);
        var val = decodeURIComponent($2);               
        val = String(val);
        obj[name] = val;
        return rs;
    });
    return obj;
}
 
Object {name: "1", dd: "ddd**"}
关于正则式部分,请参考:http://www.oschina.net/question/12_9507

转自:http://www.cnblogs.com/leee/p/5206848.html

posted on 2016-03-01 13:45  坚持不懈❥  阅读(1260)  评论(0编辑  收藏  举报