Last active
August 29, 2015 14:05
-
-
Save maxkarkowski/d07d810267a2a06d775f to your computer and use it in GitHub Desktop.
Svg Fix for Firefox when base-tag is set
This file contains 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
jQuery.svgBaseFix = function() { | |
if ($("base").length) { | |
var Url = window.location.href; | |
// Get rid of existing hashtags | |
var hash = window.location.hash; | |
var CleanUrl = Url.replace(hash, ""); | |
var origin = window.location.origin.length + 1; | |
var trimmedUrl = CleanUrl.substring(CleanUrl.length, origin); | |
$("svg:not(.no-convert) use").each(function(){ | |
var href = $(this).attr("xlink:href"); | |
var str = href.split("?"); | |
str = str[str.length - 1]; | |
$(this).attr("xlink:href", trimmedUrl + str); | |
}); | |
} | |
}; | |
$(document).ready(function(){ | |
$.svgBaseFix(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment