var_HTMLEscape=function(h){if(h ==null|| h == undefined || h ==''){return h;}
h = h.replace(/&/g,'&');
h = h.replace(/\"/g,'"');
h = h.replace(/</g,'<');
h = h.replace(/>/g,'>');
h = h.replace(/ /g,' ');return h;}
对用户输入进行HTML反转义
var_HTMLUnEscape=function(h){if(h ==null|| h == undefined || h ==''){return h;}
h = h.replace(/&(#38|amp);/g,'&');
h = h.replace(/&(#34|quot);/g,'"');
h = h.replace(/&(#60|lt);/g,'<');
h = h.replace(/&(#62|gt);/g,'>');
h = h.replace(/&(#160|nbsp);/g,' ');return h;}
随机字符串生成
var_randomString=function(){var t =0, lowerCaseAlphabet =['z','y','x','w','v','u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a'];do{
t = Math.random();}while(t ==0);
t =(t *(newDate().getTime())+'').split('.').join('1');(function(){var temIndex =0;for(var i =0; i <2; i++){do{
temIndex = Math.random();}while(temIndex <0|| temIndex >=0.26);
temIndex =parseInt(temIndex *=100);
t = lowerCaseAlphabet[temIndex]+ t;}})();return t;};
格式化数字,n:要格式化的数字,p小数点位数
var_formatNumberPrecision=function(n, p){
n =Number(n);
p =Number(p);if(isNaN(n)||isNaN(p)|| p <0){returnNumber('.');}return n.toFixed(p);};
var_getRandomInt=function(min, max){
min = Math.ceil(min);
max = Math.floor(max);return Math.floor(Math.random()*(max - min))+ min;//不含最大值,含最小值}
得到一个两数之间的随机整数,包括两个数在内
var_getRandomIntInclusive=function(min, max){
min = Math.ceil(min);
max = Math.floor(max);return Math.floor(Math.random()*(max - min +1))+ min;//含最大值,含最小值 }
对用户输入进行HTML转义 var _HTMLEscape = function(h) { if (h == null || h == undefined || h == '') { return h; } h = h.replace(/&/g, '&#38;'); h = h.rep...