I\'ve got a weird question in that I need to inject some javascript into another javascript function. I am using a framework which is locked so I can not change the existing fun
Functions are first class values in Javascript, which means that you can store them in variables (and in fact, declaring a named function is essentially assigning an anonymous function to a variable).
You should be able to do something like this:
function doSomething() { ... }
var oldVersionOfFunc = doSomething;
doSomething = function() {
var retVal = oldVersionOfFunc.apply(oldVersionOfFunc, args);
// your added code here
return retVal;
}
(But, I could be wrong. My javascript's a little rusty. ;))