iFrame之间的通信? [英] Communication between iFrames?

查看:149
本文介绍了iFrame之间的通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何让两个iFrames彼此交谈?
例如,我是第二个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.

推荐答案

如果< iframe> 元素由同一个域提供,那么他们可以直接访问对方。例如,在 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之间的通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆