I have a function that in a different frame that I need to override. In addition, I need to call the original function from within my override. To do so, I’m using the following:
myFrame.SomeFunction = (function () {
var originalSomeFunction = myFrame.SomeFunction;
return function(arg1, arg2, arg3) {
alert('In override!');
originalSomeFunction(arg1, arg2, arg3);
};
})();
When I execute this code, I get “Can’t execute code from a freed script”.
Thoughts? Is there a better way to do this? Testing in IE 6,7,8 and 9.
I figured out the solution.
Basically, you take all of the code I previously posted, and the execute it from within the context of the target frame using the eval() function. So…
Because the code is now within the target frame, it doesn’t go out of scope, and we don’t get the “freed” error anymore.