我有JavaScript功能(使用拉斐尔),点击选择区域。双击此功能应添加标记(pin.png)。单击并双击不起作用的Firefox和IE
window.onload = function() {
var R = Raphael("paper", 500, 500);
var attr = {
fill: "#EEC7C3",
stroke: "#E0B6B2",
"stroke-width": 1,
"stroke-linejoin": "round"
};
var area = {};
area.Element1 = R.path("...").attr(attr);
area.Element2 = R.path("...").attr(attr);
...
area.Element63 = R.path("...").attr(attr);
var current = null;
$("#paper").ondblclick = function (e) {
var relativeX = e.pageX;
var relativeY = e.pageY;
R.image("pin.png", relativeX, relativeY, 22, 22);
};
for (var state in area) {
area[state].color = Raphael.getColor();
(function (st, state) {
st[0].active = 0;
st[0].style.cursor = "pointer";
st[0].onmouseover = function() {
current && area[current].animate({ fill: "#EEC7C3", stroke: "#E0B6B2" }, 500) && (document.getElementById(current).style.display = "");
st.animate({ fill: st.color, stroke: "#ccc" }, 500);
st.toFront();
R.safari();
document.getElementById(state).style.display = "block";
current = state;
};
st[0].onmouseout = function() {
if (this.active == 0)
st.animate({ fill: "#EEC7C3", stroke: "#E0B6B2" }, 500);
else
st.animate({ fill: "#C05219", stroke: "#E0B6B2" }, 500);
st.toFront();
R.safari();
};
st[0].onclick = function() {
st.animate({ fill: "#C05219", stroke: "#E0B6B2" }, 500);
st.toFront();
if (this.active == 0)
this.active = 1;
else
this.active = 0;
R.safari();
};
})(area[state], state);
}
};
而且我有不同的浏览器问题:
- 在Chrome中它的工作原理差不多好了
- 在Firefox(8.0)双击没有对可以同时点击了(区域要素的工作。 Element1,[...],area.Element63)。双击应该在被点击的地方添加标记。
- 在IE(9)中既没有点击也没有双击工程。即使'onmouseout'事件也不适用于IE。
我必须使它在Firefox和IE中工作。我能做些什么来使其工作 - 特别是在Firefox中?
这里的任何帮助非常感谢!
我知道你是对的。但我需要找到一些解决方法。 – Marta 2011-12-28 16:10:24