获取url参数,替换特殊字符

 1 function GetQueryString(name){
 2         var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
 3         var r = window.location.search.substr(1).match(reg);
 4         if(r!=null){
 5             var b = decodeURI(r[2]).
 6                 replace(/\+/g," ").
 7                 replace(/%2B/g,"+").
 8                 replace(/%22/g,'"').
 9                 replace(/%27/g,"'").
10                 replace(/%2F/g,"/").
11                 replace(/%23/g,"#").
12                 replace(/%3D/g,"=").
13                 replace(/%26/g,"&").
14                 replace(/%40/g,"@").
15                 replace(/%3B/g,";").
16                 replace(/%3F/g,"?").
17                 replace(/%2C/g,",").
18                 replace(/%24/g,"$");
19             return  b
20         }
21         return null;
22     }

 

posted @ 2017-09-21 14:23  花开半夏shen  阅读(773)  评论(0编辑  收藏  举报