简体   繁体   中英

IE9 iframe window removed after will can't execute code from a freed script?

In my application I created an iframe in my lightbox, when I open the lightbox after it will call parent window function and close the lightbox, in the parent window function will create and update some DOMs, and then When I go to back the parent window I try to access those DOMs it will throw an exception "script5011: Can't execute code from a freed script".

I call the parent window function at the iframe like this window.parent.myFunc(arg1, arg2....), it will got an exception, I think that is an IE 9 new feature changed, because I tested in IE 6, 7, 8 and other browsers are working fine all, I not yet find a valid solution for IE 9, I hope can get an answer from here. any ideas?

The cause of this issue is that IE9 removes reference to a parent window's object when the frame's URL is changed subsequently and this is done to increase security. The solution for this is to setup functions in the parent window which can modify (setters & getters) the parent window data objects. You can pass objects to the parent window's function after its serialized to a string. The best way to call the parent frame's function is by calling the following in the child frame.

window.parent.eval("resetDataObject()");

and in the parent frame write something like:

var myDataObject = [];
function resetDataObject()
{
    myDataObject = [];
}

Check this post http://www.tejzpr.com/2014/10/codefix-script5011-cant-execute-code.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM