javascript - Can I intercept a function called directly? -
In this code I have created some functions named function. Then I modified the function. Prototype The application and call methods are working instead of my function code, I'm running my interception code (which shows an alert). But neither "call" nor "applicable" direct method hides in the call. Is it possible to stop it?
function.prototype call = function () {warning ("call");}; Function.prototype.apply = function () {Warning ("Apply");}; Function Some Functions () {} window.onload = function () {someFunction.call (this); // Call Alert Some functions are shown. Application (this); / / / Some functions that are applied are shown (); // How can I stop it? }
You override only a known function by setting another function to its location (Example, you can not stop all the function calls):
(function () {// An anonymous function wrapper helps keep you old Some functions are private var Some Functions = Some Functions; someFunction = function () {alert ("Blocked!"); Some Functions Old;}}) ();
Note that if some functions
were already referenced / referenced by another script before that the code had changed, then the reference is now Override by the replacement function will also not point to the original function.
Comments
Post a Comment