地址栏GET参数值"/>
jQuery获取地址栏GET参数值
jQuery获取地址栏GET参数值
封装方法:
window.location 是获取当前页面地址
// 获取地址栏参数
function GetUrlString(name){var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");var r = window.location.search.substr(1).match(reg);if(r!=null)return unescape(r[2]); return null;
}
调佣方法:
假如地址栏url是:“qweasd.php?year=2023&month=11&type=get_data”
console.log(GetUrlString("year"));
// 输出结果是 2023
console.log(GetUrlString("month"));
// 输出结果是 11
console.log(GetUrlString("type"));
// 输出结果是 get_data
更多推荐
jQuery获取地址栏GET参数值
发布评论