2012-06-20 45 views
0

我有一個難題。已經在網站上進行了研究,並嘗試了很多解決方案,但都沒有在Internet Expolorer 8(我在我的機器上安裝的版本)中工作。 在Chrome和Firefox中正常工作。 我有一個網站,用戶需要上傳10張照片。 我需要進行上傳並將它們顯示在頁面上的div上,而不用刷新,也不用重新加載頁面。 我使用了設置表單目標屬性的技術,在iframe中完成文章,iframe執行文章,當重新加載時,它只是一個帶有上傳圖像的img標籤(我在服務器端腳本中執行 - PHP) 在Internet Explorer中iframe的內容不會改變,帖子不會發生。發佈到iframe不能在Internet Explorer中工作?

有人奇蹟可以幫助我嗎? 「已經在論壇這裏研究了很多,但是這些問題大部分是由JavaScript的動態生成的內部框架,但在我的情況下,iframe是已經在HTML

這裏是我的代碼:

//javascript 

$(document).ready(function() {   
//this part works in every browser, is jut´s to triger click in input type file  
    $(".div_input_file").click(function(){    
     var rel = $(this).attr("rel");    
     $(".arq"+rel).trigger('click');    
    }) 
}); 

function loadPicture(number) 
{    
    $(".remover_produto").remove(); 
    //just a gif animation until ends animation 
    $("#image_load_"+number).attr("src","images/loading.gif"); 
    $("#image_load_"+number).css("width","172px");  
    $("#image_load_"+number).css("height","176px");  
    //when iframe load after post 
    $("#upload_target_"+number).load(function() { 
     //get image that was loaded in iframe after post 
      var image = $("#upload_target_"+number).contents().find("img").attr("src"); 
     $("#div_input_file_"+number).html("<img src='"+image+"' alt='' class='img_uploaded' />"); 
     $("#div_input_file_"+number).parent().append('<a class="remover_produto" rel="remover_'+number+'"');   
    }); 

} 

    //html 
    <iframe id="upload_target_1" class="upload_target" name="upload_target_1" src="upload.php"></iframe> 
    <div id="div_input_file_1" class="div_input_file" rel="1"> 
     <img src="images/criar_anuncio/gallery_pic05.png" alt="" id="image_load_1" /> 
    </div>  
    <form action="/upload.php" id="form_upload_1" enctype="multipart/form-data" method="post" target="upload_target_1" onsubmit="loadPicture(1)"> 
     <input name="arquivo" type="file" size="30" class="arquivo arq1" onchange="$('#form_upload_1').submit();"/> 
     <input type="hidden" name="num_imagem" value="1" /> 
    </form> 
+0

除其他錯誤的東西,這條線'(「#div_input_file _」 +號) .parent()。append('標籤。 – Ohgodwhy

+0

在我的代碼中是正確的關閉標籤,我縮短了功能減少,這裏只顯示相關的內容。 還有什麼不對? – Bruno

+0

你可以使用ajax代替iframe ... –

回答

0

終於找到了問題。 這些線路都造成問題的原因:

$(document).ready(function() {   
//this part works in every browser, is jut´s to triger click in input type file  
    $(".div_input_file").click(function(){    
     var rel = $(this).attr("rel");    
     $(".arq"+rel).trigger('click');    
    }) 
}); 

款式的輸入類型的文件,我用了以下技術: 點擊一個div,這是隱藏在輸入文件類型的觸發。

此操作會導致Internet Explorer中的錯誤。 我把正常的輸入類型的文件,而不樣式,以便我可以測試,並能證明它工作得很好

謝謝大家誰幫助

相關問題