简体   繁体   中英

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..... ". Its working fine in firefox,but in chrome it just open a new blank tab. I tried with some other urls like ' http://www.stackoverflow.com ", " http://www.google.com ". Its woking fine in both chrome and firefox.

Can anyone help me on this.

Deprecations and Removals in Chrome 58

Remove content-initiated top frame navigations to data URLs

Because of their unfamiliarity to non-technical browser users, we're increasingly seeing the data: scheme being used in spoofing and phishing attacks. To prevent this, we're blocking web pages from loading data: URLs in the top frame. This applies to <a> tags, window.open , window.location and similar mechanisms. The data: scheme will still work for resources loaded below by a page.

This feature will be removed in Chrome 60 .

<a href="data:image/png;base64,..." download="abrakadabra_iLoveCats.jpg">download id</a> – add "download=" attribute

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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