js - get-the-value-from-the-url-parameter(可以在非模态对话框中使用)

  ref: http://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-url-parameter

  函数:

function getQueryParams(qs) {

    qs = qs.split("+").join(" ");



    var params = {}, tokens,

        re = /[?&]?([^=]+)=([^&]*)/g;



    while (tokens = re.exec(qs)) {

        params[decodeURIComponent(tokens[1])]

            = decodeURIComponent(tokens[2]);

    }



    return params;

}

然后可以通过这样方式访问:  
  //var query = getQueryParams(document.location.search);
  //alert(query.foo);

你可能感兴趣的:(parameter)