JQuery .hide()在FireFox中不起作用

时间:2012-06-09 16:56:08

标签: javascript jquery css

我在Firefox中获得正确的显示/隐藏行为时遇到问题。网站适用于Chrome / Safari。现在不用担心IE了。

网站在这里:

http://chrismcaleenan.com/map/?page_id=6

当用户鼠标悬停/鼠标移动/点击Chrome / Safari中地图上的状态时,您可以看到所需的行为(忽略插入 - 这仍然是正在进行的工作)。在Firefox中,该网站似乎处理鼠标悬停,但不是鼠标输出,也不是点击。

以下是我认为的相关代码,但错误可能出现在实际的CSS或其他地方:

//actions on poly mouseover     
        for (var i = 0; i < statesPoly.length; i++) {
            (function(i){
                google.maps.event.addListener(eval(statesPoly[i]), 'mouseover', function() {
                    this.setOptions({ strokeWeight: '2' });
                    $("#"+statesPoly[i]).addClass("highlight");
                    if(map.getZoom() <= 6) 
                    $('#supp_data'+i).show();
                });
            })(i);
        }

        //actions on poly click     
        var zoomArray = new Array();

        for (var i = 0; i < statesPoly.length; i++) {
            zoomArray[i]=0;

            (function(i){
                google.maps.event.addListener(eval(statesPoly[i]), 'click', function() {
                    if (!zoomArray[i]) {                
                        map.panTo(eval(stateCenters[i]));
                        map.setZoom(7);
                        polyArray[i].setOptions({ fillOpacity: '0' });
                        zoomArray[i] = 1;   
                        $('#supp_data'+i).hide();
                        $('#inset-map').hide();
                    }
                    else {
                        map.panTo(myLatLng);
                        map.setZoom(6);
                        $('#inset-map').show();

                        //for some reason bug causes 11,12 to skip - adding manual reset
                        polyArray[i].setOptions({ fillOpacity: '.8' });
                        zoomArray[i] = 0;
                        polyArray[11].setOptions({ fillOpacity: '.8' });
                        zoomArray[11] = 0;
                        polyArray[12].setOptions({ fillOpacity: '.8' });
                        zoomArray[12] = 0;

                        for (n = 0; n < polyArray.length; n++) {
                            polyArray[n].setOptions({ fillOpacity: '.8' });
                            zoomArray[n] = 0;   
                        }

                    }
                });
            })(i);
        }

        //actions on table mouseover 
        for (var i = 0; i < statesPoly.length; i++) {
            (function(i){
                google.maps.event.addDomListener(document.getElementById(statesPoly[i]), 'mouseover', function() {
                    $("#"+statesPoly[i]).addClass("highlight");
                    polyArray[i].setOptions({ strokeWeight: '2' });
                    if(map.getZoom() <= 6)
                    $('#supp_data'+i).show();
                });
            })(i);
        }

        //actions on table click    
        var zoomArray = new Array();

        for (var i = 0; i < statesPoly.length; i++) {
            zoomArray[i]=0;

            (function(i){
                google.maps.event.addDomListener(document.getElementById(statesPoly[i]), 'click', function() {
                    if (!zoomArray[i]) {                
                        map.panTo(eval(stateCenters[i]));
                        map.setZoom(7);
                        polyArray[i].setOptions({ fillOpacity: '0' });
                        zoomArray[i] = 1;   
                        $('#supp_data'+i).hide();
                        $('#inset-map').hide();

                    }
                    else {
                        map.panTo(myLatLng);
                        map.setZoom(6);
                        $('#inset-map').show();


                        //for some reason bug causes 11,12 to skip - adding manual reset
                        polyArray[i].setOptions({ fillOpacity: '.8' });
                        zoomArray[i] = 0;
                        polyArray[11].setOptions({ fillOpacity: '.8' });
                        zoomArray[11] = 0;
                        polyArray[12].setOptions({ fillOpacity: '.8' });
                        zoomArray[12] = 0;

                        for (n = 0; n < polyArray.length; n++) {
                            polyArray[n].setOptions({ fillOpacity: '.8' });
                            zoomArray[n] = 0;   
                        }

                    }
                });
            })(i);
        }

        //actions on poly mouseout 
        for (var i = 0; i < statesPoly.length; i++) {
            (function(i){
                google.maps.event.addListener(eval(statesPoly[i]), 'mouseout', function() {
                    this.setOptions({ strokeWeight: '1' });
                    $("#"+statesPoly[i]).removeClass("highlight");
                    $('#supp_data'+i).hide();
                });
            })(i);
        }

        //actions on table mouseout
        for (var i = 0; i < statesPoly.length; i++) {
            (function(i){
                google.maps.event.addDomListener(document.getElementById(statesPoly[i]), 'mouseout', function() {
                    $("#"+statesPoly[i]).removeClass("highlight");
                    polyArray[i].setOptions({ strokeWeight: '1' });
                    $('#supp_data'+i).hide();
                });
            })(i);
        }

1 个答案:

答案 0 :(得分:0)

解决。我从来没有把我的Poly对象放在数组中。 Chrome和Safari一直在运行脚本,但Firefox已将其杀死(没有输出错误)。