获取ip和端口号
var basePath = window.location.protocol + "//" + window.location.host
获取参数
/**
* 获取URL参数
* @param 参数名
* @returns 参数值
*/
function getRequestParam(name){
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null)
return decodeURI(r[2]);
return null;
}
http://a.html?a=1&b=2
getRequestParam(a)
getRequestParam(b)