views:

46

answers:

1

Hi,

is it possible to prevent further execution of javascript?

i include some javascript scripts with php in a header (with echo ''), but there are coming some other scripts later in the page which i can not always control, so it could be that my before included (with ) mootools javascript get later overwritten by another included mootools (which then possible is an older version, or is not complete etc.)

so is there a way thet i can stop the js at one point so that later js code will not be executed?

kind of like the die(); function in php, but without that it stops the page from being loaded.

thanks in before fabian

A: 

doesnt really exist. but you can put everything into a function and "return;" any given time to exit the function which would stop the execution of the rest of the code within the function.

super simple example in standard JS:

function init() {
    if(something happens) {
         return;
    }
}
init();

in terms of stopping the browser from executing other scripts within the page - not possible.

Tobias
hm doenst really help, because i can not include the mootols library and other external classes in a function :-)in fact there is something called window.stop(); but this is like clicking the stop loading button, and this will stop loading the page...is there a way to prevent that one already loaded mootools libraray will be overwritten by a later included one?
frozeman