通过js获取url中传过来的参数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_41600552/article/details/80112742
 // 通过js获取location.href传过来的参数
	        function GetRequest() {
	            var url = location.search; //获取url中"?"符后的字串   
	            var theRequest = new Object();
	            if (url.indexOf("?") != -1) {
	                var str = url.substr(1);
	                strs = str.split("&");
	                for (var i = 0; i < strs.length; i++) {
	                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
	                }
	            }
	            return theRequest;
	        }
	        var Request = new Object();
	        Request = GetRequest();
	        var random = Request["guid"];//获取订单号  
	       // var AddresId = Request["AddressId"];
	     
	        $(".blue").text(random);
	        $(".payNow").click(function () {
	            location.href = "/OrderDetail/OrderDetailIndex?random=" + random;
	        })

猜你喜欢

转载自blog.csdn.net/weixin_41600552/article/details/80112742