I've got a parent page, with a child iframe... When clicking on a specific button inside the child iframe, I want a function to trigger as if it were originating from the parent document itself.
The function chain I have is rather long, and dependent no a lot of variables and what not. When I trigger the function (by 开发者_运维问答adding onclick to the button in the child frame), the chained functions fail because the variables are not recognized (since they don't exist within the child DOM's scope).
Any thoughtful solutions?
If a function parentFunction()
is defined in the parent frame you can call it from the child frame by saying parent.parentFunction();
(and pass it any parameters it needs for values defined in the child).
(By the way, it's probably not a good sign that you have a chain of functions that are all dependent on variables that I assume from your description are globals.)
精彩评论