1

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.

Andreas
  • 21,535
  • 7
  • 47
  • 56
Anna
  • 973
  • 4
  • 13
  • 26

2 Answers2

2

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.

Andreas
  • 21,535
  • 7
  • 47
  • 56
  • Is there any alternatives? – Anna Jan 04 '18 at 09:39
  • @Anna create a new HTML document to show in the popup on-the-fly (document.write), and have that contain an img element with the src attribute set to your data URI ...? – CBroe Jan 04 '18 at 09:40
  • @Anna [Add content to a new open window](https://stackoverflow.com/questions/10472927/add-content-to-a-new-open-window) – Andreas Jan 04 '18 at 09:42
0

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

Антон
  • 31
  • 2