获取url地址参数值方法:
1 function GetQueryString(name) 2 { 3 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i"); 4 var r = window.location.search.substr(1).match(reg); 5 if (r!=null) return unescape(r[2]); 6 return null; 7 }
例子:
1 var bg = GetQueryString("bg-color"); 2 if (bg) { 3 alert(bg) 4 }
时间: 2024-10-05 04:40:23