标签:mat url sea bsp 参数 case regexp for turn
方法一:
1 //取url参数 var type = request("type") 2 function request() { 3 var query = location.search; 4 var paras = arguments[0]; 5 if (arguments.length == 2) { 6 query = arguments[1]; 7 } 8 if (query != "") { 9 if (query.indexOf("?") != -1) { 10 query = query.split("?")[1]; 11 } 12 query = query.split("&"); 13 for (var i = 0; i < query.length; i++) { 14 var querycoll = query[i].split("="); 15 if (querycoll.length == 2) { 16 if (querycoll[0].toUpperCase() == paras.toUpperCase()) { 17 return querycoll[1]; 18 break; 19 } 20 } 21 } 22 } 23 return ""; 24 } 25 26 //调用方法 27 28 var mid=request("mid");
方法二:正则法
unction request(name) { var reg = new RegExp(‘(^|&)‘ + name + ‘=([^&]*)(&|$)‘, ‘i‘); var r = window.location.search.substr(1).match(reg); if (r != null) { return unescape(r[2]); } return null; } // 这样调用: alert(request("mid"));
标签:mat url sea bsp 参数 case regexp for turn
原文地址:http://www.cnblogs.com/xyyt/p/6068578.html