Can't execute code from a freed script

前端 未结 4 687
挽巷
挽巷 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:40

    I know this question is quite old but in case you run into this I'd suggest you use JSON.parse to create an object on the parent frame rather than eval because eval is evil (causes security issues, I think it's disabled by default in some browsers too nowadays)

    for example, if you want to call someFunction on frame 1, passing it a JSON object, use something like the below:

    var frame = window.frames[1];
    frame.someFunction( frame.JSON.parse( '{ "attr": 7 }' ) );
    

提交回复
热议问题