我有一个VEMap控件,其中包含以下相关代码:
map = new VEMap('map');
map.AttachEvent("onclick", DoContinents);
function DoContinents(event)
{
if (event.elementID != null)
{
//var shape = map.GetShapeByID(event.elementID);
//var id = shape.GetID();
//var id = event.elementID;
//alert (event.elementID);
if (event.elementID == 'msftve_1001_200000_10000')
{
map.SetCenterAndZoom(new VELatLong(15, -90), 2);
}
else if (event.elementID == 'msftve_1001_200001_10001')
{
map.SetCenterAndZoom(new VELatLong(48, 23), 2);
}
else if (event.elementID == 'msftve_1001_200002_10002')
{
map.SetCenterAndZoom(new VELatLong(4, 18), 2);
}
else if (event.elementID == 'msftve_1001_200003_10003')
{
map.SetCenterAndZoom(new VELatLong(43, 87), 2);
}
else if (event.elementID == 'msftve_1001_200004_10004')
{
map.SetCenterAndZoom(new VELatLong(-25, 134), 2);
}
cont.Hide();
vid.Show();
$('#sidebar_list').show();
$('#legend').show();
}
}
它在Chrome中运行得很好,即使在IE中也是如此!但是,当我在Firefox中加载页面时,单击我的地图图标时没有任何反应。经过进一步调查,我发现事件在所有浏览器和DoContinents运行时都会触发。在Chrome和IE中,event.elementID包含我点击的VEShape的ID,但在Firefox中,event.elementID为null(即使有一个事件对象)!显然这会导致我的DoContinents事件处理程序中的代码无法运行。为什么会在Firefox中发生,而不是在我的其他浏览器中发生?
答案 0 :(得分:0)
这是一个难以追踪的但是如果满足以下条件,则VEMap事件会中断。它们仍然会触发,但缺少关键事件数据,例如elementID。
当满足这些条件时,会出现上述问题。
请注意,Joomla会自动加载mootools。这就是发生在我身上的事。