?/** ? * 获取url参数(主要解决iframe传递参数) ? */ ?function getUrlParam(_url,key){ ??if (_url.lastIndexOf("?") != -1) { ???var queryStr = _url.substring(_url.lastIndexOf("?") + 1, _url.length); ???if(!key) ????return queryStr;//返回所有参数 ???else{ ????var params? = queryStr.split("&"); ????for(var j = 0 ;j < params.length;j++){ ?????? var tmp = params[j].split("="); ?????? if(tmp[0]==key){ ????????? return tmp[1]; ????????? break; ?????? } ????} ???} ???? ??} ?} 调用方法: var URL = document.location.toString(); getUrlParam(URL,'parmaname');
?