var $ = function(id)
{
var a = null;
a = "string" == typeof id ? document.getElementById(id) : id; return a;
};
var Class = {
create:function(){
return function(){this.initial.apply(this,arguments)};
}
}
var alpha = Class.create();
alpha.prototype={
initial:function()
{
alert("````````");
this.tm = null;
this._img = $("image");
if(this._img)
{
if(document.all)
{
alert("88888888888888");
this._img.attachEvent("onmouseover",this.hight);
this._img.attachEvent("onmouseout",this.low);
}
}
},
hight:function(){
this.tm = window.setInterval(this.highthight()
,50);
//this.tm = window.setInterval(this.highthight()
//,50);注意看这里.这个this.highthight();怎么也调不到啊。
},
low:function(){
this._img.style.filters.alpha.opacity = 30;
},
highthight:function(){
document.write("aaaaa");
if(this._img.style.filter.alpha.opacity < 100)
{
this._img.style.filter.alpha.opacity+=10;
}
else
window.clearInterval(this.tm);
}
};
var bb = new alpha();
能说明下怎么调用吗?
{
var a = null;
a = "string" == typeof id ? document.getElementById(id) : id; return a;
};
var Class = {
create:function(){
return function(){this.initial.apply(this,arguments)};
}
}
var alpha = Class.create();
alpha.prototype={
initial:function()
{
alert("````````");
this.tm = null;
this._img = $("image");
if(this._img)
{
if(document.all)
{
alert("88888888888888");
this._img.attachEvent("onmouseover",this.hight);
this._img.attachEvent("onmouseout",this.low);
}
}
},
hight:function(){
this.tm = window.setInterval(this.highthight()
,50);
//this.tm = window.setInterval(this.highthight()
//,50);注意看这里.这个this.highthight();怎么也调不到啊。
},
low:function(){
this._img.style.filters.alpha.opacity = 30;
},
highthight:function(){
document.write("aaaaa");
if(this._img.style.filter.alpha.opacity < 100)
{
this._img.style.filter.alpha.opacity+=10;
}
else
window.clearInterval(this.tm);
}
};
var bb = new alpha();
能说明下怎么调用吗?
initial:function()
{
var _self = this;// 在这存个指针
alert("````````");
this.tm = null;
this._img = $("image");
if(this._img)
{
if(document.all)
{
alert("88888888888888");
this._img.attachEvent("onmouseover",_self.hight);//调用
this._img.attachEvent("onmouseout",_self.low);//其余一样
}
}
},
alpha.prototype={
initial:function()
{
var _self = this;
this.tm = null;
this._img = $("image");
if(this._img)
{
if(document.all)
{
this._img.attachEvent("onmouseover",_self.hight);
this._img.attachEvent("onmouseout",_self.low);
}
}
},
hight:function(){
this.tm = window.setInterval(_self.highthight()
,50);
//this.tm = window.setInterval(_self.highthight()
//,50);这里调试了下,结果说_self对象为定义。
},
low:function(){
this._img.style.filters.alpha.opacity = 30;
},
highthight:function(){
document.write("aaaaa");
if(this._img.style.filter.alpha.opacity < 100)
{
this._img.style.filter.alpha.opacity+=10;
}
else
window.clearInterval(this.tm);
}
};
好像这里关系到对象的作用于问题啊。。_self是alpha的 而在hight这个函数里_self是不存在的。
this._img.attachEvent("onmouseover",_self.hight);
==> this._img.attachEvent("onmouseover",function(){_self.hight()});// 这样写全部
或者用这个 var Bind = function(object, fun){
var args = Array.prototype.slice.call(arguments, 2);
return function(){
return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
}
}//然后这样用
//this._img.attachEvent("onmouseover",Bind(this,this.hight));
意思是返回参数数组的0-2的新数组吗?
return function(){
return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
}
意思是用object对象调用方法,
args.concat(Array.prototype.slice.call(arguments)));
这里是什么意思呢?为什么要重新连接?
与其他语言的不一样啊!!!