本文介绍了iFrame 之间的通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何让两个 iFrame 相互通信?例如,我是第二个 iframe 的元素值,而第一个 iframe 上有显示元素.我需要从第二帧到第一帧的值.我该怎么做?不要说使用cookies,因为它会受到大量数据的伤害.
How can you make two iFrames talk to each other?For example I was a element value off the 2nd iframe and the 1st iframe has the display element on it. I need to get the value off the 2nd frame to the 1st. How would I do this?Don't say use cookies, cause that will hurt with massive sum of data.
推荐答案
如果 元素来自同一个域,那么它们可以直接相互访问.例如,在
iframe1
中你可以这样做:
If the <iframe>
elements are served from the same domain, then they can access each other directly. For example, in iframe1
you could do:
document.getElementById('someDiv').innerHTML =
top.document.getElementById('otherIframe').contentWindow.
document.getElementById('someOtherDiv').innerHTML;
这篇关于iFrame 之间的通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!