Last active
August 29, 2015 13:56
-
-
Save mcbrwr/9345962 to your computer and use it in GitHub Desktop.
Replace SVG in all image sources with PNG for browsers that don't support it.
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
# replace "svg" in all image src's with png for browser without svg support | |
checkA = document.implementation?.hasFeature "http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1" | |
checkB = document.implementation?.hasFeature "http://www.w3.org/TR/SVG11/feature#Shape", "1.0" | |
if not checkA and not checkB | |
for image in document.images | |
image.src = image.src.replace(/\.svg/i, '.png') |
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
// replace "svg" in all image src's with png for browser without svg support | |
if ( | |
!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && | |
!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Shape", "1.0") | |
) { | |
for(var i = 0; i< document.images.length; i++){ | |
document.images[i].src = document.images[i].src.replace(/\.svg/i, '.png') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment