2
【代码】JS获取URL参数
source link: https://feiju12138.github.io/2022/07/16/JS%E8%8E%B7%E5%8F%96URL%E5%8F%82%E6%95%B0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【代码】JS获取URL参数
2022-07-16
1
JS获取URL参数
function getUrlParam(name) {
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
let r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2])
}
return null;
}
getUrlParam("参数名")
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK