简体   繁体   English

使用 javascript 在新标签页中打开图片

[英]Open image in new tab using javascript

I want to open an image in a new tab.我想在新标签页中打开图片。 I am using the below given code我正在使用下面给出的代码

var win = window.open(url, '_blank');
win.focus();

My image url is " data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB28AAATdCAYAAABosx2OAAAgAElE..... ".我的图片 url是“ data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB28AAATdCAYAAABosx2OAAAgAElE..... ”。 Its working fine in firefox,but in chrome it just open a new blank tab.它在 firefox 中工作正常,但在 chrome 中它只是打开一个新的空白选项卡。 I tried with some other urls like ' http://www.stackoverflow.com ", " http://www.google.com ". Its woking fine in both chrome and firefox.我尝试使用其他一些网址,如“ http://www.stackoverflow.com ”、“ http://www.google.com ”。它在 chrome 和 firefox 中都很好。

Can anyone help me on this.谁可以帮我这个事。

Deprecations and Removals in Chrome 58 Chrome 58中的弃用和拆卸

Remove content-initiated top frame navigations to data URLs 将内容启动的顶部框架导航删除到数据URL

Because of their unfamiliarity to non-technical browser users, we're increasingly seeing the data: scheme being used in spoofing and phishing attacks. 由于他们不熟悉非技术浏览器用户,因此我们越来越多地看到data:欺骗和网络钓鱼攻击中使用的方案。 To prevent this, we're blocking web pages from loading data: URLs in the top frame. 为防止这种情况,我们阻止网页加载data:顶部框架中的URL。 This applies to <a> tags, window.open , window.location and similar mechanisms. 这适用于<a>标记, window.openwindow.location和类似的机制。 The data: scheme will still work for resources loaded below by a page. data:方案仍适用于页面下方加载的资源。

This feature will be removed in Chrome 60 . 此功能将在Chrome 60中删除

<a href="data:image/png;base64,..." download="abrakadabra_iLoveCats.jpg">download id</a> – add "download=" attribute <a href="data:image/png;base64,..." download="abrakadabra_iLoveCats.jpg">download id</a> – 添加“download=”属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM