IE6:setInterval,这= = window arrgh [英] IE6: setInterval, this==window arrgh

查看:87
本文介绍了IE6:setInterval,这= = window arrgh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线

this.timerId = setInterval(function(){this.step()},100)

我收到错误对话框

错误:对象不支持此属性或方法。

如果我将其更改为

this.timerId = setInterval(function(){this == window },100)

我看到了真实,这是一个令人遗憾的事实,''这个'是窗口而不是动画。


什么是正确的方法?

我想避免

this.timerId = setInterval(" Anim.step(''" + this.o.id +"'')" ;,100)

并且无需使用全局哈希数组(Anim.anims)来跟踪我的动画
(关键字:td id,值:动画实例) )必须在每一步中查找




--------

函数X (s,cp){

// cp - cell id prefix

document.write(

''< P>''+ s +''< / P>''

+''< TABLE BORDER =" 1">'

+''< TR>''

+''< TD ID =" cell_1"''

+'' onMouseOver =" X.over(this)"''

+''onMouseOut =" X.out(this)"''

+'' >此单元格得到处理< / TD>''

+''< TD ID =" cell_2"''

+''onMouseOver =" X .over(this)"''

+''onMouseOut =" X.out(this)"''

+''> me too< / TD>''

+''< / TR>< / TABLE>''




}


函数X.over(o){o.style.background =''Black''}

函数X.out(o){

o.anim = new Anim(o);

o.anim.start();

}


var Anim = function(o)

{

this.o = o

this.count = 0

}

Anim.prototype.start = function()

{

this.step();

this.timerId = setI nterval(function(){this.step()},100)

}

Anim.prototype.step = function()

{

this.count + = 4

if(this.count> 15)

this.stop()

else {

level = anim.count * 16 - 1

anim.o.style.background =''rgb(''+ level +'',''+ level +'',''+ level +'')''

}

}

Anim.prototype.stop = function()

{

clearTimeout(this.timerId)

}

-----

-

Richard A. DeVenezia,继承Text Pad Control
http://www.devenezia.com/ downloads / s ... ndex.php?id = 22

推荐答案

" Richard A. DeVenezia" < RA ****** @ ix.netcom.com>在消息中写道

news:bj ************ @ ID-168040.news.uni-berlin.de ...
"Richard A. DeVenezia" <ra******@ix.netcom.com> wrote in message
news:bj************@ID-168040.news.uni-berlin.de...
At line
this.timerId = setInterval(function(){this.step()},100)
我收到错误对话框
错误:对象不支持此属性或方法。<如果我把它更改为
this.timerId = setInterval(function(){this == window},100)
我认为是真实的,这个''这个'是窗口的可悲事实不是什么动画。

有什么方法吗?
我想避免
this.timerId = setInterval(" Anim.step(''" + this。 o.id +"'')",
100)并且避免需要全局哈希数组(Anim.anims)来保持
跟踪我的动画(key:td id,value:动画实例)在每一步都必须看起来是
At line
this.timerId = setInterval (function(){this.step()}, 100)
I get error dialog
Error:Object doesn''t support this property or method.
If I change it to
this.timerId = setInterval (function(){this==window}, 100)
I see true, the sad fact that ''this'' is window and not an anim.

What are some proper ways ?
I would like to avoid
this.timerId = setInterval ("Anim.step ( '' "+ this.o.id + " '' ) ", 100) and avoiding the need for a global hash array (Anim.anims) to keep tracking of my anims (key:td id, value:anim instance) that would have to be looked up during each step.




糟糕的表格写给自己?

我发现答案是setinterval函数(匿名或其他)

不能用这个参考e但可以使用对象的本地副本。
http://www.faqts.com/knowledge_base/...d/2311/fid/128

X.Anim.prototype.start = function ()

{

dit = this //向Nederlanders致敬

dit.step()

这个。 timerId = setInterval(function(){dit.step()},100)

}


-----

函数X(s){

document.write(

''< P>''+ s +''< / P>''

+''< TABLE BORDER =" 1">''

+''< TR>''

+''< ; TD ID =" cell_1"''

+''onMouseOver =" X.over(this)"''

+''onMouseOut =" X.out(this)"''

+''>此单元格被处理< / TD>''

+''< TD ID =" ; cell_2"''

+''onMouseOver =" ; X.over(this)"''

+''onMouseOut =" X.out(this)"''

+''> me也< / TD>''

+''< / TR>< / TABLE>''




}


函数X.over(o){o.style.background =''Black''}

函数X.out(o){

o.anim = new X.Anim(o);

o.anim.start();

}


X.Anim =功能(o)

{

this.o = o

this.count = 0

}


X.Anim.prototype.start = function()

{

dit =这个

dit.step()

this.timerId = setInterval(function(){dit.step()},100)

}

X.Anim.prototype.step = function()

{

anim = this


anim.count ++

if(anim.count> 16)

anim.stop()

else {

level = anim.count * 16 - 1

anim.o.style.background =''rgb(''+ level +'',''+ level +'',''+ level +'')''

}

}

X.Anim.prototype.stop = function()

{

clearTimeout(this.timerId)

}


X(''你好'')

-

Richard A. DeVenezia



Bad form writing to myself ?
I found the answer to be that setinterval function (anonymous or otherwise)
can''t use this reference but can use local copy of object''s this.
http://www.faqts.com/knowledge_base/...d/2311/fid/128
X.Anim.prototype.start = function ()
{
dit = this // homage to Nederlanders
dit.step()
this.timerId = setInterval (function() {dit.step()}, 100)
}

-----
function X (s) {
document.write (
''<P>'' + s + ''</P>''
+''<TABLE BORDER="1">''
+ ''<TR>''
+ ''<TD ID="cell_1"''
+ '' onMouseOver="X.over(this)"''
+ '' onMouseOut="X.out(this)"''
+ ''>this cell gets handled</TD>''
+ ''<TD ID="cell_2"''
+ '' onMouseOver="X.over(this)"''
+ '' onMouseOut="X.out(this)"''
+ ''>me too</TD>''
+ ''</TR></TABLE>''
)

}

function X.over (o) { o.style.background=''Black'' }
function X.out (o) {
o.anim = new X.Anim(o);
o.anim.start();
}

X.Anim = function (o)
{
this.o = o
this.count=0
}

X.Anim.prototype.start = function ()
{
dit = this
dit.step()
this.timerId = setInterval (function() {dit.step()}, 100)
}
X.Anim.prototype.step = function ()
{
anim = this

anim.count++
if (anim.count > 16)
anim.stop()
else {
level = anim.count * 16 - 1
anim.o.style.background = ''rgb(''+level+'',''+level+'',''+level+'')''
}
}
X.Anim.prototype.stop = function ()
{
clearTimeout (this.timerId)
}

X(''Hello'')
--
Richard A. DeVenezia


Richard A. DeVenezia写道:
Richard A. DeVenezia wrote:

function X.over(o){o.style.background =''Black ''}
函数X.out(o){
o.anim = new X.Anim(o);
o.anim.start();
}

function X.over (o) { o.style.background=''Black'' }
function X.out (o) {
o.anim = new X.Anim(o);
o.anim.start();
}



这些声明在Mozilla中产生错误(X.over和

X.out不是标识符,并且ECMA语法检查失败

函数声明)


X.over = function(o){o.style.background =''Black''}

X.out = f unction(o){

o.anim = new X.Anim(o);

o.anim.start();

}


似乎解决了这个问题,


干杯,

Dom


These declarations are generating errors in Mozilla ("X.over" and
"X.out" are not identifiers and failing ECMA syntax checks for a
function declaration)

X.over =function (o) { o.style.background=''Black'' }
X.out = function (o) {
o.anim = new X.Anim(o);
o.anim.start();
}

seems to fix it,

Cheers,
Dom


" Dom Leonard" <做************* @ senet.andthis.com.au>在消息中写道

新闻:WM ***************** @ nnrp1.ozemail.com.au ...
"Dom Leonard" <do*************@senet.andthis.com.au> wrote in message
news:WM*****************@nnrp1.ozemail.com.au...
Richard A. DeVenezia写道:
Richard A. DeVenezia wrote:

函数X.over(o){o.style.background =''Black''}
函数X.out (o){
o.anim = new X.Anim(o);
o.anim.start();
}

function X.over (o) { o.style.background=''Black'' }
function X.out (o) {
o.anim = new X.Anim(o);
o.anim.start();
}


这些声明产生错误在Mozilla中(X.over和
X.out不是标识符,并且未通过ECMA语法检查
函数声明)

X.over = function (o){o.style.background =''Black''}
X.out = function(o){
o.anim = new X.Anim(o);
o .anim.start();
}
似乎解决了这个问题,

欢呼,
Dom


These declarations are generating errors in Mozilla ("X.over" and
"X.out" are not identifiers and failing ECMA syntax checks for a
function declaration)

X.over =function (o) { o.style.background=''Black'' }
X.out = function (o) {
o.anim = new X.Anim(o);
o.anim.start();
}

seems to fix it,

Cheers,
Dom




Dom:谢谢!


我现在还有一个问题....


我想' 'stuff''将一些信息输入< td>我动态地生成了b $ b,因此它可以被事件处理程序使用,而不需要

来传递处理程序调用中的值。


这些都在IE中工作


A.< TD onmouseover =''Over(this)''style =" myProperty:myValue">



B.< TD onmouseover =''Over(this)''myProperty =" myValue">


in处理程序


A.函数Over(o){alert(o.style.myProperty)} //显示myValue

B.函数Over(o) {alert(o.myProperty)} //显示myValue


想知道这两种技术是否适用于大多数其他浏览器,如果不是,那么
将是A.版本(更广泛适用?


是否可以在

生成的TD中包含对象文字或对象引用?


-

Richard A. DeVenezia



Dom: Thank you!

I''ve another question now....

I want to ''stuff'' some information into the <td> i am dynamically
generating, so that it will be available to the event handler without having
to pass the value in the handler invocation.

Both these work in IE

A. <TD onmouseover=''Over(this)'' style="myProperty:myValue">
or
B. <TD onmouseover=''Over(this)'' myProperty="myValue">

and in the handler

A. function Over(o) { alert (o.style.myProperty) } // shows myValue
B. function Over(o) { alert (o.myProperty) } // shows myValue

Wondering if both techniques would work in most other browsers and if not
would A. version (style version) be more widespread applicable ?

Would it be possible to include an object literal or object reference in
generated TD ?

--
Richard A. DeVenezia


这篇关于IE6:setInterval,这= = window arrgh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆