I\'m using Modernizr to detect the features supported in the browser our users are running, so far so good. But I\'ve come up against a theoretical problem when testing for
I think I have an answer. I tried all sorts of techniques (repeated text chunks in the PNG source that I could manually add, etc) until I found that adding line breaks appears to do the job:
var b64test = new Image();
b64test.onload = function() {
alert("yay!")
}
b64test.onerror = function() {
alert("boo")
}
/* A 1x1 GIF image */
var base64str = "R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="
while (base64str.length < 33000) {
base64str = "\r\n" + base64str;
}
b64test.src= "data:image/gif;base64," + base64str;
Fails in IE8, works in IE9 and others. I'd love to hear any alternatives, though.