JavaScript获取URL中的参数

版权声明:本文为FromTheWind原创文章,转载请注明出处。https://blog.csdn.net/FromTheWind/article/details/78205419

function getQueryString(name){

var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");

var r = window.location.serarch.substr(1).match(reg);

//decodeURI()函数可对encodeURI函数编码过的URI进行解码;

if (r != null) {

  return decodeURI(r[2]);

return null;

你可能感兴趣的:(Js,前端)