创建动态变量和JS 中的函数
我对 JS 相当陌生,但熟悉 AS2(Flash)。在Flash中,我可以将变量放入movieclips(对象)中,并尝试使用下拉菜单执行类似的操作:
http://tamalecreative.com.au/korban/scripts/dropdown.js
具体来说:
function dropOpen() {
dropClose(this)
this.overTrue = true;
console.log(this.overTrue);
myNum = 0;
this.liLength = ($(this).find('ul').children().length)+1;
for (i=0;i<=this.liLength;i++) {
this.animateTimer = window.setTimeout(animateIn, (80 * i), this);
}
};
我的问题是“this.overTrue”布尔变量。它似乎适用于除 IE 之外的所有版本。我收到错误消息,对象“overTrue”不存在。这对我来说是有意义的,因为我从未声明过。有没有办法让我在“this”内声明变量“overTrue”?还是我以完全错误的方式处理这个问题?
提前致谢
I'm fairly new to JS but am familiar with AS2(Flash). In Flash I can put variables inside movieclips (objects) and have attempted to do something similar here with dropdowns:
http://tamalecreative.com.au/korban/scripts/dropdown.js
specifically:
function dropOpen() {
dropClose(this)
this.overTrue = true;
console.log(this.overTrue);
myNum = 0;
this.liLength = ($(this).find('ul').children().length)+1;
for (i=0;i<=this.liLength;i++) {
this.animateTimer = window.setTimeout(animateIn, (80 * i), this);
}
};
My problem is with the 'this.overTrue' boolean variable. It seems to work in everything but IE. I get the error that the object 'overTrue' doesn't exist. Which kind of makes sense to me since I never declared it. Is there a way for me to declare the var 'overTrue' inside 'this'? Or am I going about this the completely wrong way?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 IE 搞砸了最后一个参数,一个可能的解决方法可能是:
在每个“正常”浏览器中,
setTimeout
签名是这样的:在 IE 然而 中,签名是稍微不同:
Bravo IE。你又给了我一个惊喜
Seems like IE is screwing up with the last parameter, a possible workaround might be:
In every 'sane' browser,
setTimeout
signature is like this:In IE however the signature is slightly different:
Bravo IE. You've surprised me one more time