我正在尝试使用JavaScript获取URL值,到目前为止我只能获取纯数字,而不能获取混合数字和字母或仅字母的值。我找不到任何可用的函数示例,允许检索包含数字和字母的值,只有数字。我没有使用任何非字母数字字符。我试图传递的一个示例值是“42p316041610751874cm83p2306600132141”。
任何帮助都将是极好的,谢谢。
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var first = getUrlVars()["test"];
任何帮助都将是极好的,谢谢。
http://localhost/test/index.html?test=42p316041610751874cm83p2306600132141
。 - Brigand