//获取当前url地址
var curUrlPath=window.document.location.href;
假如当前url地址为:http://localhost:8080/agenda/static/groupSchedule.html?teamid=3&teamname=team2
//获取主机地址之后的部分:/agenda/static/groupSchedule.html
var pathName=window.document.location.pathname;
//获取主机地址:http://localhost:8080
var pos = curUrlPath.indexOf(pathName);
var localhostPath = curUrlPath.subString(0,pos);
//"?"后的部分,又称为查询字符串:?teamid=3&teamname=team2
var searchURL = window.document.location.search;
//获取"?"后传的参数部分:teamid=3&teamname=team2
var parameter = searchURL.substring(1, url.length);
//获取参数的值
var teamid = parameter.split("&")[0].split("=")[1];//3
var teamname =decodeURIComponent(searchURL.split("&")[1].split("=")[1],"UTF-8") ;//team2
这里的decodeURIComponent主要是为了对中文进行解码
关于decodeURIComponent() 方法对encodeURIComponent()方法编码的字符串进行解码。可以学习这篇文章