【问题标题】:Setting an ID for a path in Raphael.JS for Internet Explorer为 Internet Explorer 的 Raphael.JS 中的路径设置 ID
【发布时间】:2023-03-07 04:48:01
【问题描述】:

我真的需要为我所有的 Raphael 路径签名。我使用了这个答案how to access id attributes of any element in raphael 中发布的解决方案,它只能在 Chrome 和 Firefox 中找到。它在 Internet Explorer 中根本不起作用。它甚至阻止加载路径。有谁知道如何解决这个问题? 我知道 IE 总是很难,但我必须让它在这个浏览器上运行。

for(var i = 0; i < statePathArr.length; i++) {
    var path = mapPaper.path(statePathArr[i].coordinates).attr({
        'fill' : '#EDECE7',
        'stroke': '#666666'
    });
path.node.id(statePathArr[i].name);

【问题讨论】:

    标签: javascript jquery internet-explorer raphael


    【解决方案1】:

    您应该使用 Raphael 提供给您的内部 ID。例如:

    for(var i = 0; i < statePathArr.length; i++) {
    var path = mapPaper.path(statePathArr[i].coordinates).attr({
        'fill' : '#EDECE7',
        'stroke': '#666666'
    }); 
    path.id = statePathArr[i].name;
    }
    

    然后你只需要使用getById('') 方法。

    var getPath = paper.getById('IDoftheparh')
    

    这样您就不会使用节点,而是利用了 raphael 的跨浏览器功能。

    【讨论】:

      猜你喜欢
      • 2021-05-26
      • 2011-08-13
      • 1970-01-01
      • 1970-01-01
      • 2015-11-13
      • 1970-01-01
      • 2014-03-21
      • 2015-10-28
      • 1970-01-01
      相关资源
      最近更新 更多