Open blob objectURL in Chrome(在 Chrome 中打开 blob objectURL)
问题描述
我想在 javascript 中使用 window.open(fileObjectURL)
在 chrome 浏览器(Chrome 56.0.2924.87、Ubuntu 14.04)的新选项卡中打开 PDF.我正在从 base64 编码数据创建 blob,并创建一个像这样的 objectURL:
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);
它在最新的 Firefox 浏览器中运行良好.但在 Chrome 中,我可以看到新标签页被打开但立即关闭.所以我在控制台等中没有任何错误.它现在在 Chrome 中工作的唯一方法是将 base64 数据直接提供给 window.open(fileBase64Data)
函数.但我不喜欢在 url 中设置完整的数据.
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.
也许这是 Chrome 阻止打开 blob 的安全问题?
Maybe this is a safety issue with Chrome blocking opening of blobs?
推荐答案
原因可能是adblock扩展(我遇到了完全相同的问题).
The cause is probably adblock extension (I had exactly the same problem).
这篇关于在 Chrome 中打开 blob objectURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Chrome 中打开 blob objectURL
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06