From the Firefox developer website, I know that Firefox uses
objectURL = window.URL.createObjectURL(file);
to get url of file type, but in
if (window.URL !== undefined) {
window.URL.createObjectURL();
} else if (window.webkitURL !== undefined) {
window.webkitURL.createObjectURL();
} else {
console.log('Method Unavailable: createObjectURL');
}
Is round-about what you're looking for. Also, THIS example uses the much simpler...
window.URL = window.URL || window.webkitURL;
Simple one liner:
var createObjectURL = (window.URL || window.webkitURL || {}).createObjectURL || function(){};
You could define a wrapper function:
function createObjectURL ( file ) {
if ( window.webkitURL ) {
return window.webkitURL.createObjectURL( file );
} else if ( window.URL && window.URL.createObjectURL ) {
return window.URL.createObjectURL( file );
} else {
return null;
}
}
And then:
// works cross-browser
var url = createObjectURL( file );