我在两个标签中有相同的blob URL .
一个标签具有target ="_ blank",用于在新选项卡中打开链接,另一个用于下载.
"下载"很好,但"在新标签中打开"只适用于Firefox.对于谷歌浏览器,它会一直闪烁,打开然后在点击链接后立即关闭.
<a id="view" href="" target="_blank">View Blob in new tab</a>
<a id="download" href="" download="abc.txt">Download Blob</a>
<script>
$(function(){
var myBlob = new Blob(['Hello, I am Blob content'], {type: 'text/plain'})
var url = URL.createObjectURL(myBlob);
$("a#view").attr("href", url);
$("a#download").attr("href", url);
});
</script>
Run Code Online (Sandbox Code Playgroud)
这是Google Chrome错误吗?(我的Chrome版本是:54.0.2840.99 x64)
现场演示: