url地址
http://localhost:8080/xx/xx.htm?columnName=测试&columnId=2c908095636c27e601636cb335550006
注意:如果url中有中文,先提前用codeURI转码
获取url项目路径
var curPath=window.document.location.href;var localhostPath=curPath.substring(0,curPath.lastIndexOf("/")+1);
参考地址:http://www.cnblogs.com/l412382979/p/8574813.html
获取url中的参数
function getRequest(){var strs;
//将url再次进行解码,这样中文就不会出现乱码了var url=decodeURI(location.search);var theRequest=new Object();if(url.indexOf("?")!=-1){var str=url.substr(1);strs=str.split("&");for(var i=0;i<strs.length;i++){theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);}return theRequest;}}
使用方法
var req=getRequest();alert(req["columnName"]);
获取url中的参数
原文地址:https://www.cnblogs.com/l412382979/p/9176999.html