获取url的参数 发表于 2017-06-01 | 分类于 js | 获取url的参数 取URL中的参数12345678910/*** 取URL中的参数* @param {any} name* @returns*/function getParameterByName(name) { var match = RegExp('[?&]' + name + '=([^&]*)') .exec(window.location.search); return match && decodeURIComponent(match[1].replace(/\+/g, ' '));} 取URL中?号后面的参数1234567891011121314151617181920212223242526272829/** * 取url参数 * @return {[type]} [description] * * request("id") */function request() { var query = location.search; var paras = arguments[0]; if (arguments.length == 2) { query = arguments[1]; } if (query != "") { if (query.indexOf("?") != -1) { query = query.split("?")[1]; } query = query.split("&"); for (var i = 0; i < query.length; i++) { var querycoll = query[i].split("="); if (querycoll.length == 2) { if (querycoll[0].toUpperCase() == paras.toUpperCase()) { return querycoll[1]; break; } } } } return "";} 一颗稻草的价值,到底是多少呢?想知道的话,就订阅吧!