Skip to content

Instantly share code, notes, and snippets.

@elioverbey
Created May 5, 2014 17:22
Show Gist options
  • Save elioverbey/03a46d256add1556b583 to your computer and use it in GitHub Desktop.
Save elioverbey/03a46d256add1556b583 to your computer and use it in GitHub Desktop.
// Check if browser can handle SVG
if(!Modernizr.svg){
// Get all img tag of the document and create variables
var i=document.getElementsByTagName("img"),j,y;
// For each img tag
for(j = i.length ; j-- ; ){
y = i[j].src
// If filenames ends with SVG
if( y.match(/svg$/) ){
// Replace "svg" by "png"
i[j].src = y.slice(0,-3) + 'png'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment