js获取url制定的某个参数
<script>
function getURLParam(strParamName, url) {
var strReturn = "";
var strHref = url.toLowerCase();
if (strHref.indexOf("?") > -1) {
var strQueryString = strHref.substr(strHref.indexOf("?") + 1).toLowerCase();
var aQueryString = strQueryString.split("&");
for (var iParam = 0; iParam < aQueryString.length; iParam++) {
if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1) {
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return strReturn;
}
$(document).ready(function(){
var url="www.baidu.com?p=1323&w=js获取url地址的参数"
alert(getURLParam("w",url));
});
</script>