Answer the question
In order to leave comments, you need to log in
Why doesn't the script work when you open the site locally?
Everything works on the hosting, but when you open the site locally, just through the browser ( file:///C:/addwine/index.html ), this particular script does not work:
$('img.img-svg').each(function(){
var $img = $(this);
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
$.get(imgURL, function(data) {
var $svg = $(data).find('svg');
if(typeof imgClass !== 'undefined') {
$svg = $svg.attr('class', imgClass+' replaced-svg');
}
$svg = $svg.removeAttr('xmlns:a');
if(!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) {
$svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width'))
}
$img.replaceWith($svg);
}, 'xml');
});
Answer the question
In order to leave comments, you need to log in
security policy, can be eliminated by a browser plugin, or by running on a local server like nodejs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question