I'm not surprised to hear that. The `alert` function brings the
JavaScript interpreter to a screeching halt and blocks darned near
everything. But it's that "darned near" that introduces uncertainty:
Does whatever causes the dom:loaded event on that browser queue,
waiting for the interpreter? Or not?

E.g., I think what's happening is that you're hooking the dom:loaded
event *after* it's already fired, because you didn't hook it until
after the `alert` returned, and the `alert` waits for the user in a
very non-JavaScript way.

Fundamentally, the browser probably _should_ queue the event, but the
event queue is not the same as the execution queue on all browsers and
I wouldn't rely on it. In any case, it's trivial to reverse things and
get reliable behavior:

* * * *
document.observe("dom:loaded", function() {
    // Some code
* * * *

You still get the "foo" alert right away, it's just that you've hooked
the dom:loaded event beforehand and so presumably won't miss the event
when it occurs.

T.J. Crowder
Independent Software Consultant
tj / crowder software / com

On Aug 31, 5:39 pm, floce <florianzar...@gmail.com> wrote:
> Hi,
> I am currently facing a big problem and I hope that someone can help
> me:
> The following statement works perfectly in any browser except Internet
> Explorere:
> alert("foo");
> document.observe("dom:loaded", function() {
>     // Some code
>     alert("bar");
> });
> In this case Internet Explorer would only alert "foo" but never alerts
> "bar" while in any other browser two pop up boxes would appear. Does
> anyone know why this happens?
> Best regards,
> floce

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to