iframe calling parent javascript

后端 未结 1 1761
清酒与你
清酒与你 2020-12-05 10:12

Is it possible for me to setup an iframe so it calls a javascript function available in the window.parent.document scope?

1条回答
  •  盖世英雄少女心
    2020-12-05 10:40

    If I am understanding the question correctly, assuming functionName() is defined within the parent of iframe, you can do this within your iframe:

    window.parent.functionName();
    

    This will only work though, if both parent and iframe are on the same domain: http://softwareas.com/cross-domain-communication-with-iframes

    0 讨论(0)
提交回复
热议问题