javascript获取链接参数
var url = "http://test.cn/index.php?class=9&id=2&key=88"; function parseQueryString(url){ var params = {}; var arr = url.split("?"); if(arr.length <=1) return params; arr = arr[1].split("&"); for(var i=0,l=arr.length; i<l; i++){ var a = arr[i].split("="); params[a[0]] = a[1]; } return params; } var ps = parseQueryString(url); console.log(ps);