1 解析瀏覽器url 地址html
var urlParse=function() {
//var url = window.location.search;
var url = 'http://www.supersoco.com/CloudPay/cloud.html&sn=0868120170022575';
var obj = {};
var reg = /[?&][^?&]+=[^?&]+/g;
var arr = url.match(reg);
// ['?id=12345', '&a=b']
if (arr) {
arr.forEach((item) => {
var tempArr = item.substring(1).split('=');
var key = decodeURIComponent(tempArr[0]);
var val = decodeURIComponent(tempArr[1]);
obj[key] = val;
});
}
return obj;
};
var urlParse = new urlParse();瀏覽器