<script language="javascript">// 合并多个空白为一个空白String.prototype.resetBlank = function(){var regEx = //s+/g;return this.replace(regEx,' ');}// 除去左边空白String.prototype.Ltrim = function(){var regEx = /^/s+/g;return this.replace(regEx,'');}// 除去右边空白String.prototype.Rtrim = function(){var regEx = //s+$/g;return this.replace(regEx,'');}// 除去两边空白String.prototype.Trim = function(){var regEx = /(^/s+)|(/s+$)/g;return this.replace(regEx,'');}// 除去所有空白String.prototype.Trim = function(){var regEx = //s*/g;return this.replace(regEx,'');}// 保留数字String.prototype.GetNum = function(){var regEx = /[^/d]/g;return this.replace(regEx,'');}// 保留字母String.prototype.GetEn = function(){var regEx = /[^A-Za-z]/g;return this.replace(regEx,'');}// 保留大写字母String.prototype.GetUcase = function(){var regEx = /[^A-Z]/g;return this.replace(regEx,'');}// 保留小写字母String.prototype.GetLcase = function(){var regEx = /[^a-z]/g;return this.replace(regEx,'');}// 保留中文String.prototype.GetCn = function(){var regEx = /[^/u4e00-/u9fa5/uf900-/ufa2d]/g;return this.replace(regEx,'');}// 得到子节长度String.prototype.GetRealLength = function(){var regEx = /^[/u4e00-/u9fa5/uf900-/ufa2d]+$/;if (regEx.test(this)){return this.length * 2;} else {var oMatches = this.match(/[/x00-/xff]/g);var oLength = this.length * 2 - oMatches.length;return oLength;}}// 左边截取字符串String.prototype.Left = function(oLength){return this.slice(0,oLength);}// 右边截取字符串String.prototype.Right = function(oLength){if (this.length<oLength){return this;} else {return this.slice(this.length-oLength);}}// 获取文件全名String.prototype.GetFileName = function(){var regEx = /^.*//([^///?]*).*$/;return this.replace(regEx,'$1');}// 获取文件扩展名String.prototype.GetExtensionName = function(){var regEx = /^.*//[^//]*(/.[^/./?]*).*$/;return this.replace(regEx,'$1');}// 获取文本内容String.prototype.GetInnerText = function(){var regEx = /<//?[^>]*>/g;return this.replace(regEx,'');}// 监测是否为空String.prototype.isEmail = function(){return (this=='');}// 监测是否相等String.prototype.isEquals = function(oString){return (this==oString);}// 监测邮箱格式String.prototype.isEmail = function(){var regEx =/^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+$/;return regEx.test(this);}// String转化为NumberString.prototype.Int = function(){return isNaN(parseInt(this)) ? this.toString() : parseInt(this);}// HTML编码String.prototype.HTMLEncode = function(){var objThis = this;var oregExp = new Array(//x26/g,//x3c/g,//x3e/g,//x3e/g,//x27/g);var oTarget = new Array('&','<','>','"',''');for (var i=0; i<5; i++){objThis = objThis.replace(oRegExp[i], oTarget[i]);}return objThis;}// 字符串格式化String.prototype.encodeStr = function(){var objThis = this;objThis = objThis.HTMLEncode();objThis = objThis.replace(//n/g, '<br>');objThis = objThis.replace(//t/g, ' ');objThis = objThis.replace(//s/g, ' ');return objThis;}// Unicode转化String.prototype.AscW = function(){var strText = '';for (var i=0; i<this.length; i++){strText += '&#' + this.charCodeAt(i);}return strText;}// 数字补零Number.prototype.LengthWithZero = function(oCount){var strText = this.toString();while (strText.length<oCount){strText = '0' + strText;}return strText;}// Unicode还原Number.prototype.ChrW = function(){return String.fromCharCode(this);}// 数字数组由小到大排序Array.prototype.Min2Max = function(){var oValue;for (var i=0; i<this.length; i++){for (var j=0; j<=i; j++){if (this[i]<this[j]){oValue = this[i];this[i] = this[j];this[j] = oValue;}}}return this;}// 数字数组由大到小排序Array.prototype.Max2Min = function(){var oValue;for (var i=0; i<this.length; i++){for (var j=0; j<=i; j++){if (this[i]>this[j]){oValue = this[i];this[i] = this[j];this[j] = oValue;}}}return this;}// 获得数组值Array.prototype.Item = function(oIndex){return this[oIndex];}// 删除数组指定项Array.prototype.removeItem = function(oIndex){this.splice(oIndex,1);}// 正向查找Array.prototype.InStr = function(oTarget){for (var i=0; i<this.length; i++){if (this[i]=oTarget && typeof(this[i])==typeof(oTarget)){return i;}}return -1;}// 反向查找Array.prototype.LastInStr = function(oTarget){for (var i=this.length-1; i>=0; i--){if (this[i]=oTarget && typeof(this[i])==typeof(oTarget)){return i;}}return -1;}// 判断是否存在Array.prototype.InStrBolean = function(oTarget){for (var i=0; i<this.length; i++){if (this[i].oTarget && typeof(this[i])==typeof(oTarget)){return true;}}return false;}// 获得数字数组中最大项Array.prototype.GetMax = function(){var oValue = 0;for(var i=0; i<this.length; i++){if (this[i]>oValue){oValue = this[i];}}return oValue;}// 获得数字数组中最小项Array.prototype.GetMin = function(){var oValue = 0;for(var i=0; i<this.length; i++){if (this[i]<oValue){oValue = this[i];}}return oValue;}// 获取当前时间的GB形式Date.prototype.GetCNDate = function(){var oDateText = '';oDateText += this.getFullYear().LengthWithZero(4) + new Number(24180).ChrW();oDateText += this.getMonth().LengthWithZero(2) + new Number(26376).ChrW();oDateText += this.getDate().LengthWithZero(2) + new Number(26085).ChrW();oDateText += this.getHours().LengthWithZero(2) + new Number(26102).ChrW();oDateText += this.getMinutes().LengthWithZero(2) + new Number(20998).ChrW();oDateText += this.getSeconds().LengthWithZero(2) + new Number(31186).ChrW();oDateText += new Number(32).ChrW() + new Number(32).ChrW() + new Number(26143).ChrW()+ new Number(26399).ChrW() + newString('26085199682010819977222352011620845').substr(this.getDay()*5,5).Int().ChrW();return oDateText;}// 得到对象的绝对坐标function GetPosition(obj){var objThis = obj;var oBody = document.body;var oLeft = oTop = 0;while (objThis!=oBody){oLeft += objThis.offsetLeft;oTop += objThis.offsetTop;objThis = objThis.offsetParent;}return { left: oLeft, top: oTop };}// 取一定范围的随机数function GetRndNum(lLimit, uLimit){var orndNum = Math.floor((uLimit-lLimit+1)*Math.random()+lLimit);return orndNum;}// 获取指定位数的随机密码function GetRndPwd(oLength){var orndPwd = '';var oTempNum;var oArray = newArray('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');while (oRndPwd.length<oLength){oTempNum = GetRndNum(0,61);orndPwd += oArray[oTempNum].toString();}return orndPwd;}// 定义圆类function Circle(xPoint, yPoint, oradius){this.X = xPoint;this.Y = yPoint;this.R = oradius;this.PI = Math.PI;this.circleArea = function(){return this.PI * this.R * this.R;}this.circleLength = function(){return 2 * this.PI * this.R;}}</script>
新闻热点
疑难解答