Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

There is a chance you can intercept direct function call. This requires:

  • Either the function is created by Function.prototype.bind and you have to overwrite Function.prototype.bind before creating the function, or
  • The function is created from Function() (or new Function()) and you also have to overwrite Function function before creating the target function.

If neither of the above two can be met, the only way to intercept a direct call is to wrap the target function, which is the solution provided by AndyE http://stackoverflow.com/a/3406523/1316480https://stackoverflow.com/a/3406523/1316480

For a function that is created by function literal and is hidden in private scope, there is no way to intercept a direct call to it.

I have a blog post concludes all of these: http://nealxyc.wordpress.com/2013/11/25/intercepting-javascript-function/

There is a chance you can intercept direct function call. This requires:

  • Either the function is created by Function.prototype.bind and you have to overwrite Function.prototype.bind before creating the function, or
  • The function is created from Function() (or new Function()) and you also have to overwrite Function function before creating the target function.

If neither of the above two can be met, the only way to intercept a direct call is to wrap the target function, which is the solution provided by AndyE http://stackoverflow.com/a/3406523/1316480

For a function that is created by function literal and is hidden in private scope, there is no way to intercept a direct call to it.

I have a blog post concludes all of these: http://nealxyc.wordpress.com/2013/11/25/intercepting-javascript-function/

There is a chance you can intercept direct function call. This requires:

  • Either the function is created by Function.prototype.bind and you have to overwrite Function.prototype.bind before creating the function, or
  • The function is created from Function() (or new Function()) and you also have to overwrite Function function before creating the target function.

If neither of the above two can be met, the only way to intercept a direct call is to wrap the target function, which is the solution provided by AndyE https://stackoverflow.com/a/3406523/1316480

For a function that is created by function literal and is hidden in private scope, there is no way to intercept a direct call to it.

I have a blog post concludes all of these: http://nealxyc.wordpress.com/2013/11/25/intercepting-javascript-function/

Source Link
Neal Xiong
  • 1.1k
  • 10
  • 8

There is a chance you can intercept direct function call. This requires:

  • Either the function is created by Function.prototype.bind and you have to overwrite Function.prototype.bind before creating the function, or
  • The function is created from Function() (or new Function()) and you also have to overwrite Function function before creating the target function.

If neither of the above two can be met, the only way to intercept a direct call is to wrap the target function, which is the solution provided by AndyE http://stackoverflow.com/a/3406523/1316480

For a function that is created by function literal and is hidden in private scope, there is no way to intercept a direct call to it.

I have a blog post concludes all of these: http://nealxyc.wordpress.com/2013/11/25/intercepting-javascript-function/