我正在使用图像映射将一些图像悬停在 slider 中,效果很好,但在加载一次之前会出现闪烁,然后效果很好。有谁知道为什么会这样吗?
顺便说一句,它只发生在 FIREFOX 中
<script>
Image1 = new Image()
Image1.src = "images/slide1aroll.jpg"
function firstmap() {
document.emp.src = Image1.src;
return true;
}
</script>
<li style="width: 480px; height: 610px;"><img src="images/slide1a.jpg" name="emp" id="emp" class="emp" width="480" height="610" usemap="#model1" style="display:block; border:none;" border="0" /></li>
<map name="model1" id="model1" name="model1">
<area shape="rect" coords="31,6,289,576" href="#" onmouseover="firstmap();" onmouseout="document.emp.src = 'images/slide1a.jpg';" alt=""/>
<area shape="rect" coords="303,9,475,605" href="#" onmouseover="firstmap2();" onmouseout="document.emp.src = 'images/slide1a.jpg';" />
</map>
最佳答案
图像会闪烁,因为一旦您将鼠标悬停在图像上,就会更改图像的来源。因此,现在您的鼠标悬停在另一张图片上,而不是您想要的图片上。
一旦鼠标移到新加载的图像上,新图像就会被隐藏,因为您的鼠标现在没有悬停在旧图像上。一旦它被隐藏,您的鼠标再次移到旧图像上,因此新图像再次可见。
该过程继续产生闪烁效果。旧图-新图-旧图....等等
希望这对您有所帮助。
关于javascript - 使用图像映射时鼠标悬停时图像闪烁javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14829140/