核心提示:获取地址链接的各个参数(代码实例)var url = https://www.google.com.hk/search?safe=strictei=M_u5WvLZO4bzUrfpn_AJq=js%9...
获取地址链接的各个参数(代码实例)
var url = 'https://www.google.com.hk/search?safe=strict&ei=M_u5WvLZO4bzUrfpn_AJ&q=js%9F%&oq=js%E7%BB&gs_l=psy-ab'; var search = url.substring(url.indexOf('?')+1); var tmpArr = search.split('&'); var urlParmObj = {}; if (tmpArr.length > 0 && tmpArr[0] != '') { for (var i = 0, len = tmpArr.length; i < len; i++) { var tmp = tmpArr[i].split('='); urlParmObj[tmp[0]] = tmp[1]; } } console.log(urlParmObj);