Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs - Firefox does not open blob url in a new tab

I have the following code working fine in Chrome and IE. User clicks on an anchor tag and the code gets executed after which a pdf file is rendered in a new tab with the url blob:http://localhost:57389/5aee262a-8bc9-4943-b67f-7b76aeef4b99

vme.loadAttachment = function (attachment) {
    taskService.getAttachmentContent(attachment.Name)
        .then(function (response) {
            var file = new Blob([response], { type: attachment.Type });
            if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                window.navigator.msSaveOrOpenBlob(file);
            }
            else {
                var objectUrl = URL.createObjectURL(file);
                window.open($sce.trustAsResourceUrl(objectUrl), _blank");
            }
       })
};

However on Firefox, the new tab is opened but closes immediately on its own. Any idea what could be causing this?

like image 939
Live Free Avatar asked Mar 02 '17 06:03

Live Free


1 Answers

This thing happened to me today. I have several different VM snapshots that I use to test different "clients", and I got two of these where PDF would not open - the browser briefly flashed and the PDF did not appear.

In the end, it was an ad blocker (ABP). Simply telling it to ignore the website domain allowed PDFs to appear correctly.

like image 187
LSerni Avatar answered Oct 13 '22 02:10

LSerni