How can I make a link in IE using base64 encoding method?

I am generating base64 gifs on the fly and trying to link to a new page to open a full-size version of the gif. This works in chrome, but in IE only the img thumbnail is displayed. When someone clicks on a link in IE, a blank page opens.

Any thoughts?

thanks

Matt

echo '<a href="data:image/gif;base64,'. $data. '" target=_blank>'; echo '<img src="data:image/gif;base64,'. $data . '" width="200"/></a>'; 
+4
source share
2 answers

According to this , you cannot use uri data for navigation in IE.

  • Internet Explorer through version 7 (approximately 5% of web traffic as of September 2011), no support. However, this can be overcome by serving specific browser content. [ 6 ]
  • Internet Explorer 8 limits data URIs to a maximum length of 32 KB. (Internet Explorer 9 does not have this limitation) [ 4 ] [ 3 ]
  • In IE 8 and 9, URI data can only be used for images, but not for downloading files using navigation or Javascript. [ 7 ]
+4
source

If you use Java, you must create a servlet decoder. Example: https://gist.github.com/sjpuas/6217394 This works in all versions of IE

Using jquery replace url images like this

 if ($.browser.msie && $.browser.version == "6.0") { $("img[src*=base64]").each(function (i, img) { var base64 = $(img).attr("src").split("base64,")[1]; var encoded = encodeURIComponent(base64); $(img).attr("src", "/myApp/base64Servlet?base64=" + encoded); }); } 
+1
source

Source: https://habr.com/ru/post/1438530/


All Articles