views:

118

answers:

1

I've noticed that the close() call in javascript does not interrupt execution, for example:

if (true /* replace with some meaningful condition determining if we should close */) {
    close();
}
alert("This window is not closing...");

Since noticing this I've fixed my code up to work as intended, I just wondered why this happened?

A: 

Because close() works on the window object at the DOM level, and javascript works in javascript threads at the execution level. If you want to terminate your thread, return from your functions until you exit the pile, or throw an exception.

Alsciende