标签:var 字典 oca replace style value 函数 blog return
1、先截取请求参数字符串;
2、使用decodeURIComponent函数进行解码;
3、正则匹配出参数对象;
function getQueryObject(url) { url = url == null ? window.location.href : url; var search = url.substring(url.lastIndexOf("?") + 1); var obj = {}; var reg = /([^?&=]+)=([^?&=]*)/g; search.replace(reg, function (rs, key, value) { var name = decodeURIComponent(key); var val = decodeURIComponent(value); val = String(val); obj[name] = val; return rs; }); return obj; }
标签:var 字典 oca replace style value 函数 blog return
原文地址:http://www.cnblogs.com/bldf/p/6431523.html