views:

37

answers:

1

The first few lines of my script look like:

if (window.location.hash) {
    window.location = window.location.hash.substring(1);
}

I'd like to have the entire script "skipped" if this statement returns true. Is there any way to do this other than putting my entire script in a giant if statement?

Thanks.

+5  A: 

Just return.

if (window.location.hash) {
    window.location = window.location.hash.substring(1);
    return;
}

Note that the script will still be parsed until the end, so it has to be valid JavaScript all the way through. But I think you meant "interpreted" in the title.

Etienne Perot
Thank you. Yes, interpreted is what I meant.
ensnare