开发者

Prototype swallows javascript errors (Firefox)

Hey i'm pretty new to prototype. The problem is that javascript errors within dom:loaded开发者_运维知识库 callback functions don't get displayed in firefox (webconsole/errorconsole/firebug).

Sample1:

document.observe("dom:loaded", function() {
syntax() error()
});

Sample2:

document.observe("dom:loaded", function() {
syntax(); error()
});

Now the funny thing:

If I execute Sample1 I get an javascript error "Missing ; before statement" - ofcourse there should be a semicolon before 'error()' - so this type of error seems to work. If I execute Sample2 I don't get any error (actually it's not a syntax error anymore) but I should get a "undefined variable" error which i don't get.

Any clue what's going on here?

IE prints out the error btw


what's happening is that in sample 2 when the semicolon is added the string syntax; error acts as two individual global variables, to the compiler it looks the same as window.syntax; window.error

document.observe('dom:loaded', function() {
    syntax = 10; error = 5;
    alert(syntax + ' ' + error);
});

Try running the above example. it will help explain the issue more clearly...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜