Alternative for window.url in safari

2019-04-10 10:49发布

问题:

Is there any alternative for

window.URL = window.URL || window.webkitURL;

for Safari 5 and below?? Am trying to preview the image uploaded by the user using following snippet :

var file = jQuery('#brandImageUpload').prop("files")[0];
window.URL = window.URL || window.webkitURL ;
var blobURL = window.URL.createObjectURL(file);
$('#ibrandImage').attr('src', blobURL);
$('#brandImage').slideDown();
$(this).slideUp();

But window.URL returns undefined.

回答1:

According to http://caniuse.com, this functionality is simply not supported by Safari 5.1 and below.

It is important to understand that it is not supported by either IE9 and below, Opera Mini and some other minor desktop and mobile browsers. So, probably, it is better to avoid using it.