【问题标题】:Manipulate main frame from iFrame with jQuery?使用 jQuery 从 iFrame 操作主框架?
【发布时间】:2009-08-28 12:10:28
【问题描述】:

我在 iFrame 上作弊,以制造 AJAX 上传的错觉。上传完成后,我需要传达有关已上传到主框架的文件的信息并将其列出。

如果我在主框架中有以下 UL,并且 iFrame 中有一个名为 filename 的 JS 变量,我如何将 file_name 附加到列表中?

<ul id="uploaded_files">
  <li>My_file_name.jpg</li>
</ul>

【问题讨论】:

    标签: javascript jquery iframe


    【解决方案1】:

    取决于 jQuery 的加载位置:

    // jQuery is in the parent window
    parent.$('#uploaded_files').append('<li/>').text(filename);
    

    // jQuery is in the iframe
    $('#uploaded_files', parent).append('<li/>').text(filename);
    

    【讨论】:

    • 谢谢。这正是我想要的:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多