javascript获取url参数
对于标准形式的URL,如:https://i.cnblogs.com/EditPosts.aspx?postid=11526423&update=1,获取postid和update参数可通过以下封装函数获取
function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return ''; }