【问题标题】:Access the content of a nested Iframe访问嵌套 iframe 的内容
【发布时间】:2015-05-13 20:21:16
【问题描述】:

我正在创建一个应用程序,我想在其中访问nesend iframe 的内容。 假设我有一个页面 test.aspx 现在有一个 iframe 说 iframe1。而这个 iframe 的内容是另一个 iframe。说 iframe2 所以它是一个嵌套的 iframe。 现在我想访问 iframe2 的内容。 我们如何访问第二个 iframe 的内容,因为我必须在第二个 iframe 中搜索一些文本。 我只想使用 javascript 或 jquery 访问 iframe。

【问题讨论】:

    标签: iframe nested


    【解决方案1】:

    我终于找到了解决办法。

    document.getElementById('iframe1').contentWindow.document.getElementById('iframe2').contentWindow;
    

    对于innerHTML 使用

    frameElement.contentDocument.activeElement

    var iframeFound = document.getElementById('iframe1').contentWindow.document.getElementById('iframe2').contentWindow;
             var   ifrme = iframeFound.frameElement.contentDocument.activeElement;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-03
      • 1970-01-01
      • 2021-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多