gpt4 book ai didi

javascript - 如何在 Edge 和 IE 中使用 blob 和 createObjectURL

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:11:37 24 4
gpt4 key购买 nike

我正在使用以下代码从 AJAX 请求将 PDF 加载到窗口中:

$('#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();

这在 Chrome 和 FF 中工作正常,但 Edge 抛出以下错误:

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

有没有办法让它与 Edge 一起工作?我不想打开一个新窗口,因为它在一个弹出窗口中运行,我希望它在不打开和关闭的情况下看起来持久。正如您将注意到的,我在身份验证请求中发送了一个自定义 header ,因此我不能只制作一个 iframe 并将 src 属性设置为路径。

最佳答案

我猜你现在已经有了自己的 answer

Thank you for providing this information about the issue. We previously confirmed the problem, and have published a solution on a new build of Edge. We are resolving this issue as a duplicate of an existing internal bug report. We look forward to additional feedback you may have on how we can improve Microsoft Edge.

关于javascript - 如何在 Edge 和 IE 中使用 blob 和 createObjectURL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45176726/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com