Monday, January 18, 2010

Call a JavaScript Function with all given arguments

Sounds easy, but it is a bit tricky. Once one have to now that this:
  function test(){
ends in a recursion, because the function pointer  test, only will be resolved to the value at runtime.
I ends with this:

var tmp = fn;
fn = function(){
return tmp.apply(this, arguments);

With this snippet you can add a Google Tracking Event, just by wrap it in another js-function.

No comments:

Post a Comment