简体   繁体   English

如何使用javascript获取iframe正文

[英]how to get iframe body text using javascript

here are 02 pages: 这是02页:

iframe_content.php iframe_content.php

Some content is here.

iframe.php 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>

How do I get the iframe 's innerHTML ( Some content is here )in iframe.php page using Javascript? 如何使用Javascript在iframe.php页面中获取iframeinnerHTMLSome content is here )?

you must use 你必须使用

iframe.contentDocument

or 要么

iframe.contentWindow

for ie 对于即

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM