如何使用javascript获取iframe正文文本

时间:2013-04-14 20:16:58

标签: javascript iframe innerhtml

这是02页:

iframe_content.php

Some content is here.

iframe.php

<iframe id="sumon_iframe" src="iframe_content.php"></iframe>
<script language="JavaScript" type="text/javascript">
  var iframe_id=document.getElementsByTagName('iframe')[0].id; //i get it perfectly
  var content=iframe_id.body.innerHTML; //i don't get value
  alert(content);
</script>

如何使用Javascript在iframe.php页面中获取iframe innerHTMLSome content is here)?

1 个答案:

答案 0 :(得分:0)

你必须使用

iframe.contentDocument

iframe.contentWindow

for ie