function GetUrlValue(key, url) {
var startIndex = url.indexOf(key);
if (startIndex != -1) {
var keyValue = url.substring(startIndex);
keyValue = keyValue.replace(key + "=", "");
startIndex = keyValue.indexOf("&");
if (startIndex != -1) {
keyValue = keyValue.substring(0, startIndex);
}
startIndex = keyValue.indexOf("'");
if (startIndex != -1) {
keyValue = keyValue.substring(0, startIndex);
}
return keyValue;
}
return "";
}
直接在js文件中调用
var parmvalue= GetUrlValue('id','id=4&refer=aaaa');
就能得到id的值了