2011-04-26 45 views
0

我有下面和IE告訴我'id'爲空或不是對象。在所有其他瀏覽器中工作正常,所以認爲這可能是IE中的代碼格式問題?思考?IE中的jquery錯誤只有

function addZoom(region){ 
    $('<img />').addClass(settings.zoomClass) 
     .attr({ 
      src: settings.blankImage, 
      id: region.id 
     }).css({ 
      position: 'absolute', 
      width: region.width, 
      height: region.height, 
      top: region.top, 
      left: region.left, 
      cursor: 'pointer' 
     }).appendTo(map).click(function(){ 
      //hide neighboring bullets and zoomables 
      var width = settings.width; 
      var height = settings.height; 
      if(region.scan){ 
       width = region.scanwidth; 
       height = region.scanheight; 
      } 
      $(this).siblings().fadeOut(); 
      $(this).hide() 
        .attr('src', region.image) 
        .fadeIn('slow') 
        .animate({ 
         width: width, 
         height: height, 
         top: '0px', 
         left: '0px' 
        }, settings.zoomDuration, '', function(){ 
         displayMap(region); 
        }); 
     }); 
} 

編輯:

這裏是全碼:http://dl.dropbox.com/u/27101260/map.js

誤差以id: region.id在上面的片段被拋出。

回答

0

你的代碼中的哪個部分是拋出的錯誤?它在id: region.id?如果是這樣,它看起來像你有你的變量範圍問題region。這是互聯網瀏覽器臭名昭着的挑剔。

您可以發佈您的代碼的其餘部分,特別是region被分配的位?

+0

這是完整的代碼:[鏈接](http://dl.dropbox.com/u/27101260/map.js) 錯誤是在上面的代碼片段中引發id:region.id。 – RonnieT 2011-04-26 16:45:20

0

您正在將區域傳入addZoom函數。您訪問attr中的region.id。它看起來像(沒有任何附加信息),此時id值沒有設置。您是否在運行時檢查了代碼,以確定region是否在正確的範圍內(特別是在您撥打addZoom時)?