JQuery不在IE中工作,但在Chrome和Firefox中工作

问题描述:

我必须开发一个应用程序,它的一部分是IQuery,但我不熟悉它。 在鼠标悬停在地图上时,代码必须执行并更改背景颜色的地图和链接颜色。它适用于Chrome和Firefox,但在Inernet Exlporer中无效。 请任何帮助!JQuery不在IE中工作,但在Chrome和Firefox中工作

这里是我的代码:

<script type="text/javascript" > 
try{ 
    jQuery(document).ready(function() { 

     $.fn.maphilight.defaults = { 
      fill: true, 
      fillColor: '008000', 
      fillOpacity: 0.8, 
      stroke: false, 
      strokeColor: 'ff0000', 
      strokeOpacity: 1, 
      strokeWidth: 1, 
      fade: true, 
      alwaysOn: false, 
      neverOn: false, 
      groupBy: false 
     }; 
     $(".main-menu").mouseover(function() { 
      alert('go'); 
      var himg = $(this).attr('himg') 
      $(this).children().attr('src', himg) 
     }); 

     $(".main-menu").mouseout(function() { 
      var nimg = $(this).attr('nimg') 
      $(this).children().attr('src', nimg) 
     }); 

     $("a.fancybox").fancybox({ 
      'titlePosition': 'inside' 
     }); 

     $("a.iframe").click(function() { 
      $.fancybox({ 
       'padding': 0, 
       'margin': 0, 
       'autoScale': false, 
       'transitionIn': 'none', 
       'transitionOut': 'none', 
       'width': 980, 
       'height': 575, 
       'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'), 
       'type': 'iframe' 
      }) 
      return false; 
     }); 

     $('#photos').galleryView({ 
      panel_width: 900, 
      panel_height: 300, 
      frame_width: 160, 
      frame_height: 110 
     }); 
     $("#one").sexyCombo({ 
      emptyText: "Select" 
     }); 
     $("#two").sexyCombo({ 
      emptyText: "Select" 
     }); 
     $("#three").sexyCombo({ 
      emptyText: "Select" 
     }); 

    }); 
    } 
catch (err) 
{ 
    alert(err); 
} 
</script> 

取出try-catch电话。你似乎并不需要那里,并导致在IE浏览器的进攻。

+0

原始代码没有try-catch,我添加了这个捕获错误,但无法捕捉它。因此,我认为尝试抓住不是理由。 – Shaahin 2012-04-15 09:24:35