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


基础教程推荐
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01