在Chrome中打开blob objectURL [英] Open blob objectURL in Chrome

查看:376
本文介绍了在Chrome中打开blob objectURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Chrome浏览器(Chrome 56.0.2924.87,Ubuntu 14.04)的新选项卡中使用 window.open(fileObjectURL)在javascript中打开PDF。我创建了base64编码数据的blob,并创建了一个像这样的对象:



$ p $ const const fileObjectURL = URL.createObjectURL(fileBlob) ;

它在最新的Firefox浏览器中正常工作。但在Chrome浏览器中,我可以看到新标签打开,但立即关闭。所以我没有在控制台等出现任何错误。
它现在在Chrome中的唯一方式是将base64数据直接提供给 window.open(fileBase64Data)函数。但我不喜欢在url中设置完整的数据。



也许这是Chrome阻止打开Blob的安全问题?

解决方案

原因可能是adblock扩展(我有完全相同的问题)。


I want to open a PDF in a new tab in chrome browser (Chrome 56.0.2924.87, Ubuntu 14.04) using window.open(fileObjectURL) in javascript. I am creating the blob from base64 encoded data and do create an objectURL like this:

const fileObjectURL = URL.createObjectURL(fileBlob); 

It works fine in latest Firefox browser. But in Chrome I can see that the new tab gets opened but then closed immediately. So I don't get any error in the console etc. The only way it works in Chrome now is to give the base64 data directly to the window.open(fileBase64Data) function. But I don't like the complete data being set in the url.

Maybe this is a safety issue with Chrome blocking opening of blobs?

解决方案

The cause is probably adblock extension (I had exactly the same problem).

这篇关于在Chrome中打开blob objectURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆