Skip to content

Instantly share code, notes, and snippets.

@maxkarkowski maxkarkowski/svgBasefix.js
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.