码迷,mamicode.com
首页 > Web开发 > 详细

JS采用正则表达式获取地址栏参数

时间:2018-11-15 13:57:12      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:null   regexp   地址栏   name   function   exp   sea   amp   query   

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

JS采用正则表达式获取地址栏参数

标签:null   regexp   地址栏   name   function   exp   sea   amp   query   

原文地址:https://www.cnblogs.com/liw66/p/9962725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!