Created
September 1, 2015 22:17
-
-
Save plexus77/330ece3d41a3247e0383 to your computer and use it in GitHub Desktop.
A cross browser fallback if svg is not supported.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")) { | |
var imgs = document.getElementsByTagName('img'); | |
var svgExtension = /.*\.svg$/ | |
var l = imgs.length; | |
for(var i = 0; i < l; i++) { | |
if(imgs[i].src.match(svgExtension)) { | |
imgs[i].src = imgs[i].src.slice(0, -3) + 'png'; | |
console.log(imgs[i].src); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment