我正在尝试在 ESRI Map Journal 模板上设置一个简单的脚本,其中链接图像在悬停时发生变化。通常我会做这样的事情;
<script language="javascript">
function MouseRollover(MyImage) {
MyImage.src = "image2";
}
function MouseOut(MyImage) {
MyImage.src = "image1";
}
</script>
<a href="link">
<img src="image1" onMouseOver="MouseRollover(this)" onMouseOut="MouseOut(this)">
</a>
但是,这在 Map Journal 上不起作用,因为模板会自动插入一个带有指针事件的包装 div:all; 财产。之所以这样做,是因为 Map Journal 模板会自动将图像设置为在灯箱中打开。所以为了抵消这一点,并允许图像链接到其他东西,使用了包装器 div。所以它变成了;
<a href="link">
<div id="image-wrapper" style="pointer-events: all; display: inline-block; cursor: default; max-width: 100%; position: relative;">
<img src="image1" onMouseOver="MouseRollover(this)" onMouseOut="MouseOut(this)"></div>
</a>
但是,这样做会停用上述悬停脚本。如果我用指针事件覆盖 div CSS:无,悬停脚本有效,但链接不起作用。
有关解决此问题的任何建议,以便链接和悬停都可以工作?我考虑过更改脚本,以便鼠标悬停在 div 上起作用,但随后它会更改图像。如何在 JS 中编写代码?或者也许有不同的解决方案?