获取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 }