Skip to content

Instantly share code, notes, and snippets.

@stephanie-walter
Created May 19, 2013 15:55
Show Gist options
  • Save stephanie-walter/5608071 to your computer and use it in GitHub Desktop.
Save stephanie-walter/5608071 to your computer and use it in GitHub Desktop.
Detecting SVG support
function setCSS() {
var docBody = document.getElementsByTagName('body');
docBody[0].className = 'svg';
}
function SVGDetect() {
var testImg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D';
var img = document.createElement('img');
img.setAttribute('src', testImg);
img.onload = setCSS;
}
window.onload = SVGDetect;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment