iframe中的getElementById [英] getElementById within iframe
本文介绍了iframe中的getElementById的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问:我有一个iframe调用页X,第X页是一个div w / id = test
。该测试div的值是bubbles。在父页面上,我需要读取div的值并将其存储为javascript var。
Q: I have an iframe calling page X, on page X is a div w/ id=test
. The value of this test div is "bubbles". On the parent page I need to read the value of the div and store it as a javascript var.
结果:在父页面上有一个 document.write(iframedivvalue);
输出将= iframe中div的值。
Outcome: on the parent page have a document.write(iframedivvalue);
output that will = whatever the value of the div inside the iframe.
注意:
- 截至目前,页面X位于
不同的域名。 - 我不想设置iframe中的任何
,只需读取div
值。
推荐答案
如果域不匹配,您仍将被同源策略阻止。如果你只是想抓住一个值,那无所谓。
You will still be blocked by the same-origin policy if the domains mismatch. Doesn't matter if you're just trying to grab a value.
这篇关于iframe中的getElementById的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文