I’m working on a project that has many iframes that are opened and closed in a parent window. I have an object that needs to be defined and shared between the iframes. The issue I’m running into is that when the iframe that created the object on top is closed the functions associated with it are lost.
Is there a way I can define an object on top that will be accessible from my iframes even after the original iframe goes out of scope?
In case someone else stumbles across this. What I’ve found is that Javascript functions are stored as references, so defining top.func = function(){…} from an iframe will create a reference to the function on the top. This means that if the iframe is lost so is the function.
My solution was to create an iframe that’s hidden in the background and created when that function needs to be defined.