整个Iframe引用的页面是通过form提交,返回的数据流。这种情况下 用$("#IframeID").contents().find("div").eq(0).html()获取不到页面里的div对象。有办法解决吗?
<form id="edocForm" name="edocForm" action="' + edocUrl + '" target="Edoc_from" method="post" >
<input type="hidden" id="hw_document_code" name="hw_document_code" />
</form><iframe id="Edoc_from" name="Edoc_from" class="iframe01" width="800" height="680" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>
<form id="edocForm" name="edocForm" action="' + edocUrl + '" target="Edoc_from" method="post" >
<input type="hidden" id="hw_document_code" name="hw_document_code" />
</form><iframe id="Edoc_from" name="Edoc_from" class="iframe01" width="800" height="680" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>
如果那个div还没加载肯定是获取不到
我自己专门写了个按钮,等他加载完成以后才点按钮的。但连body都获取不到,最多只能到iframe那一层
主要这个流不是我们这边的,是从接口那边调来的页面数据。我们自己的页面,不用form来提交的话,相同结构下那句话能获取到里面的东西。用了form获取就不行了。
试试js原生方式$("#IframeID").get(0).contentWindow().document.getElementsByTagName("div")[0].innerHTML;
Uncaught TypeError: Property 'contentWindow' of object #<HTMLIFrameElement> is not a function
$("#IframeID").get(0).contentWindow.document.getElementsByTagName("div")[0].innerHTML;