随笔分类 - javasccript
摘要:var flash = { types: { }, event: function( type ) { var listeners = this.types[type]; if( listeners ) { for( var i = 0; i < listeners.length; ++i ) { listeners[i](); } } }, addEventListener: function( type, fn ) { if( !t...
阅读全文
摘要:call() 方法它的第一个参数用作this的对象,其他参数都直接传递给函数自身;重写上个例子:function ClassA(sColor){ this.color = sColor; this.sayColor = function(){ alert(this.color) }};function ClassB(sColor,sName){ ClassA.call(this,sColor)//这里的this 是指ClassB this.name = sName; this.sayName = function(){ a...
阅读全文
摘要:面向对象语言 必须支持继承机制,既一个类能重用另一个类的方法和属性.1、继承方式对象冒充工作原理:构造函数使用this关键字,给所有属性和方法赋值,因为构造函数值只是一个函数,所以可以使ClassA的构造函数成为ClassB的方法 。然后调用它,ClassB就会收到ClassA的构造函数中定义的属性和方法。考虑下面例子function ClassA(sColor){ this.color = sColor; this.sayColor = function(){ alert(this.color) }};function ClassB(sColor){ t...
阅读全文
摘要:修改对象1、创建新方法javascript 乐趣的一部分就是创建属于你自己的方法。你可以用它来做一些常用的操作。提高效率(人肉效率,程序效率.....)。考虑下面例子:1 var iNum = 10;2 iNum = iNum.toString(16); 3 alert(iNum); // output "a"这里使用 Number 对象的 toStrong 方法, 将 iNum 转换成16进制的字符.如果我们需要频繁的操作此类数字.比如在颜色数据的操作上.你那么我们可以这么创建新的方法重写上面的例子:1 Number.prototype.toHexString = fun
阅读全文
摘要:对象基础封装 --- 把相关信息(无论数据或方法)储存在对象上的能力;聚集 --- 把一个对象储存在另一个对象上的能力;继承 --- 有另一个类(或多个)得来类的属性和方法的能力;多态 --- 编写能以多种方法运行的函数或方法的能力.1.工厂方式var oSite = new Object;oSite.name="noyobo";oSite.url = "http://noyobo.cnblogs.com/";oSite.showName = function(){ alert(this.name);};此代码创建对象 oSite,接着设置了几个属性.它
阅读全文
摘要:如果您在此刻浏览本站. 降看到雪花纷飞的效果.来源:http://www.somethinghitme.com/2011/10/05/jquery-snowfall-1-5-update-now-with-snow-buildup/也可以下载这里:http://files.cnblogs.com/noyobo/snowfall.jquery.rar本站使用的是 :http://files.cnblogs.com/noyobo/snowfall.jquery.js经过我修改的使用方法:$(document).snowfall({yous options});/* flakeCount : 35.
阅读全文
摘要:正则表达式是一种通用的标准,大部分计算机语言都支持正则表达式,包括as3,这里转摘出了一些常用的正则表达式语句,大家用到的时候就不用自己写了 ^\d+$ //匹配非负整数(正整数 + 0) ^[0-9]*[1-9][0-9]*$ //匹配正整数 ^((-\d+)|(0+))$ //匹配非正整数(负整数 + 0) ^-[0-9]*[1-9][0-9]*$ //匹配负整数 ^-?\d+$ //匹配整数 ^\d+(\.\d+)?$ //匹配非负浮点数(正浮点数 + 0) ^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\...
阅读全文
摘要:<script type="text/javascript">nowDay = new Date()var oAstro =["12月22日-1月19日","1月20日-2月18日","2月19日-3月20日","3月21日-4月20日","4月21日-5月20日","5月21日-6月21日","6月22日-7月22日","7月23日-8月22日","8月23日-9月22日",&quo
阅读全文
摘要:<script>//获取url地址 收藏功能 兼容fffunction shoucang(Title,geturl){ //Title=document.title; //geturl=document.location.href;if (document.all){window.external.addFavorite(geturl,Title);}elseif (window.sidebar){window.sidebar.addPanel(Title, geturl, "");}}</script><img src="mages
阅读全文
浙公网安备 33010602011771号