【问题标题】:Image preview not displayed in safari 5.1.7Safari 5.1.7 中未显示图像预览
【发布时间】:2013-10-20 06:23:38
【问题描述】:

您好,我有图像选择器控件,用于在将图像上传到服务器后选择图像。而且我必须在同一页面中预览选定的图像,这在所有浏览器中都可以正常工作,但在 safari(我的版本 5.1.7)中却不行。这是我的代码。请提前帮助解决这个问题。

jQuery('#image').on('change', function () 
{
  ext = jQuery(this).val().split('.').pop().toLowerCase();
  if (jQuery.inArray(ext, ['gif', 'png', 'jpg', 'jpeg']) == -1) {
   resetFormElement(jQuery(this));
   window.alert('Not an image!');
  }
  else
  {
    file = jQuery('#image').prop("files")[0];
    blobURL = window.URL.createObjectURL(file);
    jQuery('#image_preview img').attr('src', blobURL);
    jQuery('#image_preview').slideDown();
    jQuery(this).slideUp();
  }
});

【问题讨论】:

    标签: jquery html


    【解决方案1】:

    你需要 Safari 6

    Browser compatibility

    Chrome          Firefox (Gecko) IE      Opera           Safari (WebKit)
    8 (webkitURL 23)    4.0 (2)     10      15 webkitURL    6 webkitURL
    

    这是一种较旧的方法,可能会有所帮助

    Image Upload with Preview and Delete

    【讨论】:

      猜你喜欢
      • 2014-08-18
      • 2016-11-15
      • 1970-01-01
      • 2011-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-16
      相关资源
      最近更新 更多