2013-01-08 47 views
2

默認的Android瀏覽器不工作我有這個代碼的問題:這個javascript函數

function handleFileSelect(evt) { 
    evt.stopPropagation(); 
    evt.preventDefault(); // stop default 

    console.log('ejecutado handleFileSelects') 

    var divOrigen = evt.target.parentNode; //get the div of the input 
    var divDestino = $(divOrigen).find('img'); //get the div for preview the img 
    var inputDestino = $(divOrigen).find('input[type="file"]'); // the input file 
    var files = evt.target.files; //get files in array 

    if (files.length) { 
     for (var i = 0, f; f = files[i]; i++) { 
     if (!f.type.match('image.*')) { 
      continue; 
     } 
     var reader = new FileReader(); 
     reader.onload = (function (theFile) { 
      return function (e) { 
       $(divDestino).attr('src', e.target.result); //read files content to preview in div 
      }; 
     })(f); 
     reader.readAsDataURL(f); 
     } 
     $(inputDestino).popover('destroy'); 
    } else { 
     evt.stopPropagation(); 
     evt.preventDefault(); 
     $(inputDestino).popover('show'); 
     console.log('files is empty'); 
     $(divDestino).attr('src', '/images/index/publicacion/dragAndDropHere.png'); 
    } 
} 

此代碼改變div的背景。 div的用途是預覽輸入文件的圖像。在Opera,Firefox,Internet Explorer和Safari中它工作正常,但是當我在Android平板電腦上試用它時,沒有任何反應。有沒有類似於Android的Firebug的工具?或者我可以用於Android平板電腦的任何框架?

回答

1

嘗試從圖像源除去第一/,所以不是

$(divDestino).attr('src', '/images/index/publicacion/dragAndDropHere.png'); 

你有

$(divDestino).attr('src', 'images/index/publicacion/dragAndDropHere.png'); 
+0

dragAndDropHere.png是,默認情況下在div出現一個指示區下降的圖像圖像...這不是錯誤... – andrescabana86

相關問題