![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
javascript
yzy0612
这个作者很懒,什么都没留下…
展开
-
javascript下的trim()方法
/*** 用正则表达式将前后空格(包括占两个字符的中文空格);* BY YangZY* 2007-4-28*/String.prototype.trim = function() { return this.replace(/(^[/s/u3000原创 2007-08-07 13:04:00 · 385 阅读 · 0 评论 -
javascript按字节长度截取字符串,并添加后缀.
源码如下:/** * description : 得到字符串的字节长度; * @author YangZY; * @version 0.2; * @return 返回字符串的字节长度(eg:"一二12"的字节长度是6); * 发布时间 : 2007.8.26; * 地点 : 哈尔滨; */String.prototype.getLength=function(){ var text=th原创 2007-08-26 22:21:00 · 930 阅读 · 0 评论 -
javascript得到字符串的字节长度(字节数)
在 javascript下得到字符串的真正长度,即字节长度(字节数)代码如下:/** * description : 得到字符串的字节长度; * @author YangZY; * @version 0.2; * @return 返回字符串的字节长度(eg:"一二12"的字节长度是6); * 发布时间 : 2007.8.26; * 地点 : 哈尔滨; */String.prototype.原创 2007-08-26 22:08:00 · 536 阅读 · 0 评论 -
javascript 设置浮点小数保留位数函数
/** * description : 浮点小数格式化; */function formatFloat(src, pos) { if (pos !=0 && !(pos)) { pos = 2; } return Math.round(src*Math.pow(10, pos)) / Math.pow(10, pos);}原创 2007-08-08 14:34:00 · 756 阅读 · 0 评论 -
javascript下Date对象的时间格式化函数
已经记不得在那里找到的了,感谢原作者提供的这么好的东西.这个函数我一直在用,用起来也很方便./*** 时间对象的格式化;*/Date.prototype.format = function(format){ /* * eg:format="YYYY-MM-dd hh:mm:ss"; */ var o = { "M+" : this.getMonth()+1, //month原创 2007-08-07 21:42:00 · 19047 阅读 · 2 评论 -
javascript 继承-代码的重用
方法1: 在Prototype JavaScript framework, version 1.4.0中,可以使用Object.extend(destination, source) 方法进行类的继承。例子: var ClassA = Class.create();ClassA.prototype = { initialize : function () { }, fu原创 2007-08-05 22:33:00 · 364 阅读 · 0 评论