用以下面的函数:
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
);
}
如果需要decode参数中其它某些URL特殊字符,把decodeURI改成decodeURIComponent
本文介绍了一个实用的JavaScript函数,用于从当前URL中提取指定名称的参数,并通过decodeURI进行解码。若需解码更多特殊字符,文章建议使用decodeURIComponent替代。
用以下面的函数:
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
);
}
如果需要decode参数中其它某些URL特殊字符,把decodeURI改成decodeURIComponent
578

被折叠的 条评论
为什么被折叠?