IE10/9 中的 .load() 函数不工作

.load() function in IE10/9 not working

在后端 (wordpress) 我有用户 select 一个图标,然后输出一串文本。我使用 .icons class 搜索所有图标并用相应的 svg 替换它找到的字符串。它工作得很好,但在 IE9/10 中,加载函数不起作用,字符串也没有被替换。

我读到其他人也有类似的问题,但是当尝试实施类似的修复时,none 起作用并且字符串仍然得到输出 [CSS Tricks, Another Stack Question]。

到目前为止我还没有运气,所以想知道是否有人可以给我更好的见解。

JS / JQuery

function icons() {
  $('.icons').each(function() {
    var counter = 0;
    var select =  $(this).html();
    var url = location.origin;
    var path = "/wp-content/themes/Proxy-Engine/dist/assets/icons/svg/";
    var ext = ".svg";
    var icon = url+path+select+ext;
    $(this).load(icon, null, function() {
      $('.icons svg g').removeAttr('stroke');
    });
    var loc = location.origin;
    $(this).html(select)
  });
}

IE9/10不支持window.location.origin。我从 var 图标中删除了 url,并将其设为相对路径。

感谢大家的帮助。

function icons() {
  $('.icons').each(function() {
    var counter = 0;
    var select =  $(this).text();
    var path = "/wp-content/themes/Proxy-Engine/dist/assets/icons/svg/";
    var ext = ".svg";
    var icon = path+select+ext;
    $(this).load(icon, function() {
      $('.icons svg g').removeAttr('stroke');
    });
  });
}