2、ubstr(i,1); if (patrn.exec(temp)== null){ icount=icount+1 } else { icount=icount+2 } strre+=temp } else { break } } return strre+ "..."}2、原生JavaScri
3、pt获取域名主机1function getHost(url){23456789101112 var host= "null"; if(typeof url== "undefined"
4、
5、 null ==url){ url=window.location.href; } var regex=/^w+://([^/]*).*/; var match=url.match(regex); if(typeof match!= "undefined" &
6、& null !=match){ host=match[1]; } return host;}3、原生JavaScript清除空格1234String.prototype.trim= function(){ var reExtraSpace=/^s*(.*?)s+$/; return this.replace(reExtraSpace, "$1")}4、原生JavaScript替换全部123String.prototype.replaceAll= functi
7、on(s1,s2){ return this.replace(new RegExp(s1, "gm"),s2)}5、原生JavaScript转义html标签123function HtmlEncode(text){ return text.replace(/&/g, '&').replace(/"/g,'"').replace(//g, '>')}6、原生JavaScript还原html标签123function HtmlDecode(text){
8、 return text.replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>')}7、原生JavaScript时间日期格式转换123456789101112131415161718Date.prototype.Format= function(formatStr){ var str=formatStr; var Week=['日', '一', '二', '三', '四', '五', '六
9、']; str=str.replace(/yyyy
10、YYYY/, this.getFullYear()); str=str.replace(/yy
11、YY/,(this.getYear()%100)>9?(this.getYear()%100).toString(): '0' +(this.getYear()%100)); str=str.replace(/MM/,(this.getMonth()+1)>9?(this.getMonth()+1).toString(): '0'+(th
12、is.getMonth()+1)); str=str.replace(/M/g,(this.getMonth()+1)); str=str.replace(/w
13、W/g,Week[this.getDay()]); str=str.replace(/dd
14、DD/, this.getDate()>9? this.getDate().toString(): '0' +this.getDate()); str=str.replace(/d