function Class1()
{
var oldValue='';
var name='xu';
var id='1';
this.setName=function(n)
{
oldValue=name;
name=n;
this.propertyChange('name',oldValue,n);
}
this.setID=function(n)
{
oldValue=id;
id=n;
this.propertyChange('id',oldValue,n);
}
this.display=function()
{
alert(name+'\'s id is :'+id);
}
}
Class1.prototype={
propertyChange:function(propertyName,oldValue,newValue)
{
alert(propertyName+'\'s value changed from '+oldValue+' to '+newValue);
}
};
var c=new Class1();
c.setName('xu22');
c.setID('5');
c.display();
if (!Object.prototype.watch)
{
Object.prototype.watch = function (prop, handler)
{
var oldval = this[prop], newval = oldval,
getter = function ()
{
return newval;
},
setter = function (val)
{
oldval = newval;
return newval = handler.call(this, prop, oldval, val);
};
if (delete this[prop])
{
if (Object.defineProperty) // ECMAScript 5
{
Object.defineProperty(this, prop, {get: getter,set: setter});
}
else if (Object.prototype.__defineGetter__ && Object.prototype.__defineSetter__)
{
Object.prototype.__defineGetter__.call(this, prop, getter);
Object.prototype.__defineSetter__.call(this, prop, setter);
}
}
};
}
if (!Object.prototype.unwatch)
{
Object.prototype.unwatch = function (prop)
{
var val = this[prop];
delete this[prop];
this[prop] = val;
};
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有