html页面:
<iframe src="" id="frame" name="frame"></iframe>
<form id="fileform" name="fileform" method="post" action="" target="operate" enctype="multipart/form-data">
  <input type="file" name="filedata" id="filedata" />
</form>
<script type="text/javascript">
  $('filedata').onchange=function(){
    $('fileform').action='upfile.asp';
    $('fileform').submit();
  }
</script>
upfile.asp页输出结果,如下:
20120101.jpg请问:怎么才能在html页面通过js获取upfile.asp上传完后的结果,即 20120101.jpg
谢谢在upfile.asp中用js返回的方法就算了window.parent......

解决方案 »

  1.   

    <script type="text/javascript">
      $('filedata').onchange=function(){
        $('fileform').action='upfile.asp';
        $('fileform').submit();    if (iframe.attachEvent){
          iframe.attachEvent("onload", function(){
            alert(GetIframeInnerHtml($id('operate')));
          });
        } else {
          iframe.onload = function(){
            alert(GetIframeInnerHtml($id('operate')));
          };
        }
      }function GetIframeInnerHtml(objIFrame) 

            var iFrameHTML = ""; 
            if (objIFrame.contentDocument)    
            { 
                    // For NS6 
                    iFrameHTML = objIFrame.contentDocument.innerHTML;    
            }    
            else if (objIFrame.contentWindow)    
            { 
                    // For IE5.5 and IE6 
                    iFrameHTML = objIFrame.contentWindow.document.body.innerHTML; 
            }    
            else if (objIFrame.document)    
            { 
                    // For IE5 
                    iFrameHTML = objIFrame.document.body.innerHTML; 
            } 
        
            return iFrameHTML; 

    </script>百度的上面这种方法,alert的结果是undefined
      

  2.   

    <form>的target指向存在问题,应提交给iframe