解析query string的javascript函数

function fillDefaultValues() {
    var qs = location.search.substring(1, location.search.length);
    var args = qs.split("&");
    var vals = new Object();
    for (var i = 0; i < args.length; i++) {
        var nameVal = args[i].split("=");
        var temp = unescape(nameVal[1]).split('+');
        nameVal[1] = temp.join(' ');
        vals[nameVal[0]] = nameVal[1];
    }
    return vals;
}

 

参考资料:

http://blogs.msdn.com/b/sharepoint/archive/2007/06/21/using-javascript-to-manipulate-a-list-form-field.aspx

posted on 2010-05-27 21:56  中道学友  阅读(466)  评论(0编辑  收藏  举报

导航

技术追求准确,态度积极向上