function getUrlParam(name){
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
var result = window.location.search.substr(1).match(reg)
return result ? decodeURIComponent(result[2]) : null ;
}
获取url参数
最新推荐文章于 2023-08-21 23:19:42 发布
本文介绍了一个实用的JavaScript函数,用于从当前页面的URL中提取指定名称的参数值。该函数通过正则表达式匹配查询字符串,并使用decodeURIComponent解码返回参数值。
769

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



