2012-06-09 79 views
0

我遇到了在Firefox中正確顯示/隱藏行爲的問題。網站在Chrome/Safari中運行。現在不擔心IE。JQuery .hide()在FireFox中不工作

網站是在這裏:

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); 
     } 
+0

當您嘗試在Firefox中進行調試時,它會說什麼? – Joey

+0

不會引發任何錯誤。 –

回答

0

解決。我從來沒有把我的一個Poly對象放在數組中。 Chrome和Safari一直在運行該腳本,但Firefox將其殺死(無錯誤)。

+0

你應該接受你的答案,這樣SO問題就解決了。 – arttronics