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

JS获取URL参数

时间:2018-02-06 14:57:36      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:arc   script   match   fun   需要   .exe   blog   java   exe   

 
//获取URL参数
 name 参数名称 
 
var getParam = function(name){
        var search = document.location.search;
        var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
        var matcher = pattern.exec(search);
        var items = null;
        if(null != matcher){
                try{
                        items = decodeURIComponent(decodeURIComponent(matcher[1]));
                }catch(e){
                        try{
                                items = decodeURIComponent(matcher[1]);
                        }catch(e){
                                items = matcher[1];
                        }
                }
        }
        return items;
};

 

银联二维码H5项目,支付成功页面,需要获取url参数。

JS获取URL参数

标签:arc   script   match   fun   需要   .exe   blog   java   exe   

原文地址:https://www.cnblogs.com/ourLifes/p/8422265.html

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