1 jQuery.extend({ 2 /** 3 * Returns get parameters. 返回获取参数。 4 * 5 * If the desired param does not exist, null will be returned 如果所需的参数不存在,将会返回null 6 * 7 * @例子 value = $.getURLParam("paramName"); 8 */ 9 getURLParam: function(strParamName,url){ 10 var strReturn = ""; 11 var strHref = url||window.location.href; 12 var bFound=false; 13 14 var cmpstring = strParamName + "="; 15 var cmplen = cmpstring.length; 16 17 if ( strHref.indexOf("?") > -1 ){ 18 var strQueryString = strHref.substr(strHref.indexOf("?")+1); 19 var aQueryString = strQueryString.split("&"); 20 for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ 21 if (aQueryString[iParam].substr(0,cmplen)==cmpstring){ 22 var aParam = aQueryString[iParam].split("="); 23 strReturn = aParam[1]; 24 bFound=true; 25 break; 26 } 27 28 } 29 } 30 if (bFound==false) return null; 31 return strReturn; 32 } 33 });