IE8 对 Prototype 抱怨“未定义”为空或不是对象”

发布于 2024-08-08 00:53:55 字数 539 浏览 5 评论 0 原文

我有一个使用 new Element('div') 动态创建的元素,然后淡入、移动和淡出。在每个浏览器中,我的代码都按预期工作 - 除了 IE 之外的每个浏览器。

Internet Explorer 抱怨 'undefined' 为 null 或不是对象原型的灯塔

为了得到这个错误,我写了:new Message('Your contact information has been saving');

我的 Message 类的源代码可以在 这个要点

I have an element that is dynamically created with new Element('div') and is then faded in, moved, and faded out. In every browser, my code works as expected – every browser but IE.

Internet Explorer complains that 'undefined' is null or not an object exactly as documented on Prototype's Lighthouse.

To get the error, I write, new Message('Your contact information has been saved');

The source for my Message class is available at this gist.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦冥 2024-08-15 00:53:55

“Undefined is null of not an object”是一个非常基本的错误消息,可以在多种情况下产生(它是 JScript 中空指针异常的有效等价物)。所以你的错误不太可能与上面提到的相同。

但我没有得到那个错误。我收到“无效参数”,这似乎是由以下原因引起的:

new Effect.Move(_div, {sync: true, x: '50%', y: 35, mode: 'relative' })

如果我将 % 更改为正常的整数像素值,则它可以正常工作。 x 记录为仅接受整数值不是 CSS 测量; '%' 在其他浏览器中也不起作用(充当 0)。我猜你已经创建了这个功能!

正如 Fabien 提到的,您还需要插入一些 var 语句,否则您会在全局变量上乱写乱画,如果您尝试创建其中两个,则 Message 将会崩溃。另外,请注意不要在数组文字中留下尾随 , (由于注释行),因为这会使 IE 感到困惑。

“Undefined is null of not an object” is a very basic error message that can be produced in a huge range of situations (it's JScript's effective equivalent of a null pointer exception). So it's unlikely yours is the same error as mentioned above.

I don't get that error though. I get “Invalid argument”, which seems to be caused by:

new Effect.Move(_div, {sync: true, x: '50%', y: 35, mode: 'relative' })

If I change the % to a normal integer pixel value it works fine. x is documented as accepting only an integer value not a CSS measurement; the '%' doesn't work for me in other browsers either (acts as 0). I guess you've made this feature up!

As Fabien mentioned, you also need to insert some var statements, otherwise you're scribbling over the globals and Message will blow up if you try to create two of them. Plus take care not to leave a trailing , in an array literal (due to the commented line), as this confuses IE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文