整个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>

解决方案 »

  1.   

    感觉应该可以获取,你什么时候执行的$("#IframeID").contents().find("div").eq(0).html()?
    如果那个div还没加载肯定是获取不到
      

  2.   


    我自己专门写了个按钮,等他加载完成以后才点按钮的。但连body都获取不到,最多只能到iframe那一层
      

  3.   


    主要这个流不是我们这边的,是从接口那边调来的页面数据。我们自己的页面,不用form来提交的话,相同结构下那句话能获取到里面的东西。用了form获取就不行了。
      

  4.   

    大概知道原因了,那个页面没加载jquery节点的吧?
    试试js原生方式$("#IframeID").get(0).contentWindow().document.getElementsByTagName("div")[0].innerHTML;
      

  5.   

    这个其实我试过的....js就直接报错了
    Uncaught TypeError: Property 'contentWindow' of object #<HTMLIFrameElement> is not a function
      

  6.   

    我写错了而已,你修正啊
    $("#IframeID").get(0).contentWindow.document.getElementsByTagName("div")[0].innerHTML;
      

  7.   

    Uncaught TypeError: Cannot call method 'getElementsByTagName' of undefined。不行啊,我检查不出问题啊