📜  如何从 JavaScript 代码示例中检索 GET 参数

📅  最后修改于: 2022-03-11 15:03:46.948000             🧑  作者: Mango

代码示例3
function getSearchParameters() {     var prmstr = window.location.search.substr(1);     return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {}; }  function transformToAssocArray( prmstr ) {     var params = {};     var prmarr = prmstr.split("&");     for ( var i = 0; i < prmarr.length; i++) {         var tmparr = prmarr[i].split("=");         params[tmparr[0]] = tmparr[1];     }     return params; }  var params = getSearchParameters();