我正在尝试使用dojo.connect将onMouseDown事件连接到图像,如:
dojo.connect(dojo.byId("workpic"), "onMouseDown", workpicDown);
function workpicDown()
{
alert("mousedown");
}
类似的代码几行后,我将onMouse *事件连接到dojo.body确实完全正常工作.
但是当我点击图像时,我没有看到警报窗口,因此事件不会被调用.这是为什么?
解决方法:
当与DOM事件一起使用时,“onMouseDown”应该全部为小写,而不是Widget事件.尝试:
dojo.connect(dojo.byId("workpic"), "onmousedown", workpicDown);
A note about the event names: Event
names now are lower case, except in
special cases (e.g., some Mozilla DOM
events). Dojo will add “on” to your
event name if you leave it off (e.g.,
‘click’ and ‘onclick’ are the same
thing to dojo). This differs from
Widget Events in the sense Dijit uses
mixedCase event names, to avoid
potential conflicts.