图像映射与覆盖不工作在IE

Image map with overlay not working in IE

本文关键字:工作 IE 覆盖 映射 图像      更新时间:2023-09-26

我正在尝试使用html图像地图创建一个覆盖的交互式地图。查看,请访问:http://www.surge.ca/testing/WFA2100/index.html


解释:

当你将鼠标悬停在地图的<area>上时,它会显示一个带有链接的覆盖。为了防止当你移动到它时覆盖关闭,因为你不再悬浮在该区域上,我在它关闭覆盖之前使用setTimeout


问题:

它的工作原理就像我想在每个浏览器,但IE。在ie7和ie8中,当你将鼠标悬停在另一个<area>上方的覆盖层上时,它会立即切换到该<area>的覆盖层。

起初,我认为这是一个z-index问题,其中<area>的z-index在覆盖之上,但我认为我的z-index设置正确。我也在想,这可能只是IE如何处理图像映射?


代码:

下面是设置事件的代码。

jQuery(function($){
    // binds mouseenter and mouseleave to <area>
    $('area').bind('mouseenter',function(){
        sectionNum = this.hash;
        sectionNum = sectionNum.replace(/#/,'');
        showOverlay(sectionNum);
        clearTimeout(timer);    
    }).bind('mouseleave', function(){
        timerClose();
    });
    $('.map_info').bind('mouseenter', function(){
        clearTimeout(timer);
    }).bind('mouseleave', function(){
        timerClose();
    });
});
// sets timer before closing to allow cancel
var timer;
function timerClose(){
    timer = setTimeout(function(){hideOverlay();},500);
}

问题是IE在悬停结束时清除setTimeout。我没有运行你的代码,但我有同样的问题,cpu可以通过传递setTimeout函数作为字符串来修复它。

例如,setTimeout(alert('hi'), 1000)没有在一个功能上工作,在悬停状态下运行,但setTimeout("alert('hi')", 1000)正在工作。在你的代码中可能会替换

timer = setTimeout(function(){hideOverlay();},500);

timer = setTimeout("function(){hideOverlay();}",500);

解决问题。IE运行的代码似乎在全局范围内以字符串传递。

我也可以看到你有jQuery在你的页面。有一个叫做hoverIntent的jQuery插件,它可以很好地处理悬停延迟。也许插件编写者编写了更多的跨浏览器代码。

让我知道它是否有效。:)