How to use blobs and createObjectURL in Edge and IE

I use the following code to load PDF files into a window from an AJAX request:

$('#divEmbedPdf').empty();

var req = new XMLHttpRequest();
req.open('GET', '/api/read/file?p_key=<some key>', true);
req.responseType = 'blob';
req.setRequestHeader('SomeAuthHeader', 'SomeTokenValue');
req.onload = function (event) {
    var fblob = req.response;

    $('<iframe/>', {
        src: window.URL.createObjectURL(fblob),
        frameborder: 0,
        marginheight: 0,
        marginwidth: 0,
        css: {
            position: 'absolute',
            width: '100%',
            height: '100%'
        }
    }).appendTo($('#divEmbedPdf'));
}
req.send();

This works fine in Chrome and FF, but Edge throws the following error:

SEC7134: Resource 'blob:C88E2211-80B6-4933-B5E1-0E8DE3665368' not allowed to load.

Is there any way to make this work with Edge? I do not want to open a new window, because it works in a pop-up window that I want to look constant without opening or closing. As you will notice, I am sending a custom header to an authentication request, so I cannot just create an iframe and set the src attribute to the path.

+4
source share
1 answer

I guess you have an answer

. Edge. . , Microsoft Edge.

+1

Source: https://habr.com/ru/post/1681737/


All Articles