Can't execute code from a freed script

前端 未结 4 680
挽巷
挽巷 2021-01-21 05:51

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 followin

4条回答
  •  轮回少年
    2021-01-21 06:20

    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...

    myFrame.eval("SomeFunction = (function () {var originalSomeFunction = SomeFunction; return function (arg1, arg2, arg2) {alert('Inside override!'); originalSomeFunction(arg1, arg2, arg3);};})();");
    

    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.

提交回复
热议问题