2012-03-08 63 views
3

我只在IE9得到一個錯誤「SCRIPT5007:預期的對象」。有2個相同的錯誤。一個是在的$(document)在beggining,另一個被標記爲「< - 錯誤在這裏」JS錯誤「對象預期」的錯誤說,只有在IE9

<script> 
     $(document).ready(function(){ 
      var imagePath = "/sites/all/modules/custom/sixdegrees_right_menu/images/"; 
      $(".menu-holder").mouseover(function() 
      { 
       //$(this).children(".menu-title").children(".menu-bg").hide(); 
       //$(this).children(".menu-title").children(".menu-name").css({"float":"none"}); 
       //$(this).children(".menu-title").children(".menu-text").css({"float":"none"}); 

       var imgSrc = $(this).children(".menu-icon").find("img").attr("src"); 
       imgSrc = imgSrc.replace(imagePath, ""); 
       imgSrc = imagePath + "h-" + imgSrc; 
       $(this).children(".menu-icon").find("img").attr("src", imgSrc); 
       <- error here 
       //$(this).children(".menu-title").children(".menu-name").children("img").animate({"left": "0px"}, "slow"); 
       //$(this).children(".menu-title").children(".menu-text").animate({"left": "0px"}, "slow"); 
      }); 
     }); 
    </script> 

這裏也有,我沒有足夠的權限來刪除它,除非我可以要求某些註釋行一些東西。

+0

您可以發佈相關的HTML? – jbabey 2012-03-08 04:35:48

+0

使用您在IDE中查找和替換的任何實例,搜索$並用jQuery替換。我只是猜測你可能有一些MVC框架或安裝的東西。 – Ohgodwhy 2012-03-08 05:15:03

回答

2

類型=「文/ JavaScript的」添加到您的腳本標籤,並確保您成功,包括jQuery的嘗試使用它之前。

+2

+1類型。但如果你不包括jQuery的事前,該錯誤會像「'$'沒有定義」 – Joseph 2012-03-08 04:30:18

+1

雖然需要type屬性爲有效的HTML,在實踐中是沒有必要的(並且一直不是很很長時間),除非頁面中已經使用了其他腳本語言。在任何情況下,如果jQuery的並未被列入那麼除非一些其他的腳本已經定義了'$'一個值,那麼一個錯誤將在第一個'$'被拋出,這將是,它永遠不會達到「錯誤這裏「線。 – RobG 2012-03-08 04:32:34

+0

@ Joseph-in IE錯誤是由OP報告的「Object expected」。 – RobG 2012-03-08 04:33:48