5

I am generating a base64 gif on the fly and am trying to make a 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 shows. When someone clicks on the 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>';
2
  • What version of IE are you using? Commented Oct 9, 2012 at 2:23
  • So far I have just used IE 9. Thanks. Commented Oct 9, 2012 at 2:27

2 Answers 2

4

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

  • Internet Explorer through version 7 (approximately 5% of web traffic as of September 2011), lacks support. However this can be overcome by serving browser specific 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 data URIs can only be used for images, but not for navigation or Javascript generated file downloads. [7]
Sign up to request clarification or add additional context in comments.

1 Comment

I had seen the first 2 bullet points but not the third. That would explain it. Thanks for pointing that out Musa.
1

If you use Java, you would create a servlet decoder. Like this: https://gist.github.com/sjpuas/6217394 This works me in all IE versiones

With 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 Comment

Wouldn't this easily hit the max url length of 2083 chars on IE?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.