日期:2014-05-16 浏览次数:20381 次
??? /*获取url参数值*/
??? var url="http://www.i170.com/test.do?a=123&b=456&c=789&url=http://www.i170.com/test.do?a=123&b=456&c=789";
??? function getQueryStr(str){
??????? var rs = new RegExp("(^|)"+str+"=([^\&]*)(\&|$)","gi").exec(url);
??????? return rs;
??? }
??? alert(getQueryStr("b"));
??? /*扩展String类,使之具有去除左右空白的功能*/
??? String.prototype.LTrim=function(){
??? ??? var space=new String(' ');
??? ??? var s=new String(this);
??? ??? if(space.indexOf(s.charAt(0))!=-1){
??? ??? ??? var j=0,i=s.length;
??? ??? ??? while(j<i&&space.indexOf(s.charAt(j))!=-1){
??? ??? ??? ??? j++;
??? ??? ??? }
??? ??? ??? s=s.substring(j,i);
??? ??? }
??? ??? return s;
??? };
??? String.prototype.RTrim=function(){
??? ??? var space=new String(' ');
??? ??? var s=new String(this);
??? ??? var j=s.length-1;
??? ??? if(space.indexOf(s.charAt(j))!=-1){
??? ??? ??? while(j>=0&&space.indexOf(s.charAt(j))!=-1){
??? ??? ??? ??? j--;
??? ??? ??? }
??? ??? ??? s=s.substring(0,j+1);
??? ??? }
??? ??? return s;
??? };
??? String.prototype.Trim=function(){
??? ??? var s=new String(this);
??? ??? return s.LTrim().RTrim();
??? };
??? alert('['+('???? a??? b???? c????? ').Trim()+']');