【问题标题】:How to get element from inside iframe如何从 iframe 内部获取元素
【发布时间】:2016-09-02 12:15:07
【问题描述】:

您好,我有 iframe,在 iframe 中我需要获取父窗口的元素。我该怎么做?

    index.html

child.html 通过id获取父元素

【问题讨论】:

标签: javascript html


【解决方案1】:

如果您在父窗口中有var myVar,您可以使用window.parent.myVar 从子窗口访问它。

注意:这只有在孩子和父母都在同一个域上时才有效。

请参阅here 了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-27
    • 2017-05-04
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    • 2021-11-01
    相关资源
    最近更新 更多