Skip to content

Instantly share code, notes, and snippets.

@maxkarkowski
Last active August 29, 2015 14:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save maxkarkowski/d07d810267a2a06d775f to your computer and use it in GitHub Desktop.
Svg Fix for Firefox when base-tag is set
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