在 iframe 和父级之间传递 jquery 变量 [英] Pass jquery variables between iframe and parent
本文介绍了在 iframe 和父级之间传递 jquery 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用 jQuery 和 iframe
.获取并传递 var
从 iframe
到 body
和从 body
到 iframe
.我有以下示例.如何单击iframe
中的按钮并使其在body
#test
上生效.在 iframe 中准备好 var x 怎么样.
How can I work with jQuery and iframe
. Get and pass var
from iframe
to body
and from body
to iframe
. I have the following example. How can I click the button in iframe
and make it take effect on the the body
#test
. How about ready var x in iframe.
<body>
var x = "whatever";
<div id"test"></div>
<iframe width="200px" height="200px" src="page.html"></iframe>
</body>
在 page.html 里面我有
Inside page.html i have
<button>clickme</button>
<script>
var elm = $('<span>content</span>');
elm.appendTo('#test')
</script>
推荐答案
$("#myid", top.document);
或
$("#myid", parent.document.body);
这将使您能够访问 IFRAME 的容器
This will give you access to the container of the IFRAME
根据:http://groups.google.com/group/jquery-en/browse_thread/thread/5997ef4a60a123af
这篇关于在 iframe 和父级之间传递 jquery 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文