//删除querystring指定key,__VIEWSTATEGENERATOR & __VIEWSTATE
function removeQueryStringKey(query, key) {
    var p = "&" + key + "=[^&]{0,}";
    p += "|" + key + "=[^&]{0,}&";
    var reg = new RegExp(p);
    return query.replace(reg, "");
}

//获取querystring指定key的value
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}


    //添加querystring到cookie
    function addCookieQuery(query) {
        var vars = query.split('&');
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split('=');
            var key = decodeURIComponent(pair[0]);
            var value = decodeURIComponent(pair[1]);
            $.cookie(key, value);
        }
    }

Chobits
7.4k 声望171 粉丝

保卫骡博 Chobits#3780