我在 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.html
和 back.html
位于同一域中(对于 same-origin 策略)
关于javascript - 在框架内调用特定的 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8710100/