I am still getting into JavaScript and got a problem I do not understand.
The Code:
function loadDocumentFromResponse(requestObject, filename){
console.log('Response from Server gets analyzed...');
if( typeof URL === "function" ){
console.log('Will use the URL function to revoke an object url');
var url = URL.createObjectURL(requestObject.response);
var a = document.createElement('a');
a.setAttribute('href', url);
a.setAttribute('download', filename);
a.click();
URL.revokeObjectURL(url);
// is working with chrome and gets me a download which works
// firefox also gets into this tree but it does nothing!
}else{
// IE, Maxton, Safari and Opera are throwing an Exception, will figure out whats wrong, later....
console.log('Function URL ist unbekannt');
}
}
My problem is actually the IF case... Where chrome is exactly doing what I expect, it gives me a download. But Firefox, gots the function URL. too and does not create a download from the blob response...
Whats my fault? And any hint for IE, etc.?
cu
Aucun commentaire:
Enregistrer un commentaire