如何使用javascript获取iFrame src内容? [英] How to get iFrame src content using javascript?
本文介绍了如何使用javascript获取iFrame src内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个iFrame,其内容在另一个iFrame中。我想获得内部iFrame的 src
内容。我怎么能用javascript做这个?
I have an iFrame, content of which is inside another iFrame. I want to get the inside iFrame's src
content. How can I do this using javascript?
推荐答案
外页:
<html>
<body>
<iframe id="ifr1" src="page1.htm"></iframe>
<iframe id="ifr2" src="http://www.google.com"></iframe>
</body>
</html>
page1.htm:
page1.htm:
<html>
<body>
<script type="text/javascript">
document.write(parent.document.getElementById('ifr2').src);
</script>
</body>
</html>
这篇关于如何使用javascript获取iFrame src内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文