JS12 -- url问号后的数据

www.xiaoheikeji.net?open_id=12

function GetQueryString(name)
{
  let reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  let r = window.location.search.substr(1).match(reg);
  if(r!=null)return unescape(r[2]); return null;
}

GetQueryString('open_id')          // 12

posted @ 2019-02-23 14:24  Yo!  阅读(616)  评论(0编辑  收藏  举报