javascript - 在框架内调用特定的 id

标签 javascript iframe

我在 mainpage.html 中有一个 iframe 标记,该 iframe 会回调.html..

有没有办法只调用back.html中的特定id以在iframe中显示..

详细信息: 我在 back.html 中有 25x25 的表格。最初 iframe 显示所有 625 个单元已最小化。每个单元格都有一个唯一的 ID。我可以调用特定单元格仅在 iframe 内显示(原始大小)吗?

或者有其他方法可以解决这个问题..请指定

最佳答案

试试这个代码:

var iframe    = document.getElementById('your-iframe-ID'), 
                /* or other kind of reference to the iframe DOM node */

    iframeDoc = ((!!iframe['contentDocument']) 
              ? iframe.contentDocument 
              : iframe.contentWindow.document),

    cell      = iframeDoc.getElementById('your-cell-ID');
                /* this is a reference to cell inside the iframe */

当然,我假设 mainpage.htmlback.html 位于同一域中(对于 same-origin 策略)

关于javascript - 在框架内调用特定的 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8710100/

相关文章:

javascript - AngularJS 中 ng-src 的图像加载事件

javascript - 显示函数的参数

javascript - iFrame WYSIWYG 字体大小不会重置

javascript - 如何同步单独 iframe 中的两个文本区域?

javascript - 为什么网站倾向于使用新窗口进行身份验证而不是插入的对话框/iframe?

javascript - 如何在源代码中使用 JavaScript 将每个 http 更改为 https?

javascript - 指向捆绑在一起的 JS 模块的常见依赖关系的最佳方法是什么?

javascript - 一行中的多个变量赋值

java - 使用 Jsoup 解析 iframe 中的 YouTube 缩略图

使用 Chrome 开发者工具调试 iframe