2

このコードに問題があります:

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 タブレットに使用できるフレームワークはありますか?

4

1 に答える 1

1

画像ソースから最初の / を削除してみてください。

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

あなたが持っている

$(divDestino).attr('src', 'images/index/publicacion/dragAndDropHere.png');
于 2013-01-08T18:57:08.370 に答える