我有一个带有图像映射的图像。图像映射将图像分成 4 个扇区(上、右、下、左)。每次您单击一个扇区(图像映射区域)时,图像都会旋转,直到该扇区位于顶部。我创建了一个小例子来展示我是如何做到的:http: //jsfiddle.net/44YhF/
或作为完整的 HTML 文档:
<html>
<head>
<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="js/jQueryRotate.js" type="text/javascript"></script>
<!-- QueryRotate is from: https://jqueryrotate.googlecode.com/files/jQueryRotate.js -->
<script type="text/javascript">
rotated=0;
aktuell=0;
isRotating=false;
jQuery(document).ready(function() {
$("#map area").click(function(event) {
console.log("click");
    event.preventDefault(); //bringt auch nichts
    if(!isRotating||true) {  //true hier raus nehmen damit die einzelnen Abschnitte nur klickbar sind wenn gerade keine Rotation läuft
        isRotating=true;
        pos=0;
        if(aktuell<$(this).attr("pos")) {
            pos=$(this).attr("pos");
        } else {
            pos=parseInt($(this).attr("pos"))+4;
        }
        rotatedif=360-(Math.abs(aktuell-pos)*90);
        rotate=rotated+rotatedif;
        aktuell=$(this).attr("pos");
        $("#cycle").rotate({animateTo:rotate, duration:(10-(Math.abs(aktuell-pos)))*300, callback: setRotatingOff});
        rotated=rotate;
    }
});
function setRotatingOff() {
    isRotating=false;
}
});
</script>
</head>
<body>
<img src="http://uploads6.wikipaintings.org/images/m-c-escher/circle-limit-iii.jpg!Blog.jpg" id="cycle" border="0" usemap="#map">
<map id="map" name="map">
<area shape="poly" coords="82,73,250,248,429,91," href="#" alt="" title=""   pos="0"/>
<area shape="poly" coords="421,85,250,246,417,419," href="#" alt="" title=""   pos="1"/>
<area shape="poly" coords="249,247,412,418,75,414," href="#" alt="" title=""   pos="2"/>
<area shape="poly" coords="248,247,74,411,82,76," href="#" alt="" title=""   pos="3"/>
</map>
</body>
</html>
这适用于 Chrome、Firefox、IE9/10。但在 IE8 中,图像仅在您第一次单击区域时旋转。第一次点击后,当你点击一个区域时不再触发点击事件。
我该怎么做才能让它在 IE8 中工作?