如何从父窗口访问iframe中的元素? [英] How to access element present inside a iframe from parent window?
本文介绍了如何从父窗口访问iframe中的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个iframe。我想要访问iframe中存在的表。我想从iframe的父窗口访问它。我已经写过JS,如
Document.getElementById(table Id);
但结果为空。什么是获得它的过程?
谢谢
解决方案
x = document.getElementById(iFrameId );
x.contentDocument.getElementById(tableId);
如果您可以使用jQuery,我猜它可以跨浏览器使用
$(#iFrameId)。contents()。find(#tableId)
I have an iframe. I want to access a table which present inside iframe.I want to access it from parent window of iframe. I have written JS like
Document.getElementById("table Id");
But the result come null. What is the process to get it? thanks
解决方案
x=document.getElementById("iFrameId");
x.contentDocument.getElementById("tableId");
if you can use jQuery i guess it will work across browsers
$("#iFrameId").contents().find("#tableId")
这篇关于如何从父窗口访问iframe中的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文