1

在玩Raphael.js Australia map时,我尝试通过更改路径末尾的属性来为每个元素分配 URL:

country.cityone = R.path("coordinates").attr({href: "cityone.html"}).attr(attr);
country.citytwo = R.path("coordinates").attr({href: "citytwo.html"}).attr(attr);
...

以上适用于 Firefox、Chrome 等,但 IE6-IE9 无法使用该声明。

所以我想在之后声明另一个变量var country并将网址分配给它:

var url = {};
url.cityone = "cityone.html";
url.citytwo = "citytwo.html";

然后在鼠标单击/向下时调用它:

    st[0].onmousedown = function() {

    current && country[current] && document.getElementById(“current”).appendChild(url);

    };

但是,它根本不起作用。显然我没有从函数中正确调用,将每个 URL 与其各自的城市相关联。我错过了什么?

4

2 回答 2

1

我没有对此进行测试,但我很确定您应该取消 href 并添加鼠标事件:

country.cityone = R.path("coordinates").attr(attr).click(function(){
  window.location.href = "cityone.html";
});

我很确定这会奏效。

于 2012-08-07T12:58:27.930 回答
1

只是为了关闭这个问题,经过几次试验,我最终发现IE需要双击click(function(){才能打开href页面

我发现在上面的代码中:

country.cityone = R.path("coordinates").attr(attr).click(function(){
  window.location.href = "cityone.html";
});

我必须更改.click(function(){.mousedown(function(){IE 才能正常工作。

谢谢@Zevan!干杯

于 2012-08-15T19:19:34.670 回答