rapadura
rapadura

Reputation: 5300

How do I stop Javascript execution? And all timers? (How to stop a function from polling - or monkeypatching it)

I want to stop a script from executing, similar to what the Esc key does in Firefox. It stops all Javascript from running on that page as well as all gif animations.

Is there a function I could call which would stop everything?

Upvotes: 1

Views: 436

Answers (2)

hugomg
hugomg

Reputation: 69984

Depending on how the offending module is organized, perhaps you can monkey-patch it without having to change its source code.

For example, if the annoying polling function is global or namespaced you can try to replace it with a useless stub:

//save the old version of the function, in case
//we need to restore it afterwards
var nasty_function = His.Namespaced.Evil.func;

//put our own stub in place
His.Namespaced.Evil.func = function(what, args, it , should, receive){
    return somthing_that_signals_a_failed_poll;
}

Upvotes: 2

Jon
Jon

Reputation: 437854

No, there is nothing like that. And there's also no real reason for it: you write the code, you can make it stop doing things if you want to.

Plus: if there were such a function that stopped all JS activity... how would you make it start up again?

Upvotes: 2

Related Questions