2010-07-31 3 views
1

우리의 개발자 중 하나가 배너 회전기를 사용하며, IE가 제대로 작동하지 않을 때 IE는 30 번째 줄에 오류가 발생합니다. 아래에 "***** ERROR ON NEXT LINE"으로 표시). $$ ('. banner')를 정렬 할 수 없습니까?프로토 타입 Javascript 오류 (IE에만 해당) '개체가이 속성 또는 메서드를 지원하지 않습니다.'

오류 : 의 모든 후 프로토 타입을 1.6.0.3

function changeBanners() { 

    // banners are now sorted by their z index so that 
    // the ones most in front should be most on top in the DOM 
    // ***** ERROR ON NEXT LINE 

    banners = $$('.banner').sort(function (a,b){ 
    _a = parseInt(a.style.zIndex); 
    _b = parseInt(b.style.zIndex); 
    return _a < _b ? 1 : _a > _b ? -1 : 0; 
    }); 

    // increment z index on all of the banners 
    Element.extend(banners); 

    banners.each(function (banner){ 

    Element.extend(banner); 
    banner.style.zIndex = parseInt(banner.style.zIndex) + 1; 
    }); 

    // move the first banner to be the last 
    first_banner = banners.shift(); 
    banners.push(first_banner); 

    // set it invisible 
    Effect.toggle(first_banner.id , 'appear' , { 
    duration: 2.0, 
    afterFinish: function(){ 
     first_banner.style.zIndex = 0; // update its z index so that it is at the end in the DOM also 
     first_banner.show();   // make it reappear so that when the one in front of it disappears, it will show through 
    } 
    }); 
}; 
+1

빈 함수를'sort' 메소드에 전달하고 에러를 검사하도록하십시오. –

+0

빈 함수가 "Number Expected"를 던졌습니다. a> b를 sort 함수로 반환하면 "개체가이 속성 또는 메서드를 지원하지 않습니다."라는 오류가 반환되었습니다. – Jarrett

+1

'forEach'를'each'로 변경하십시오. (! this.currentlyExecuting) : –

답변

1

* 한숨 *

를 사용

'개체가이 속성 또는 메서드를 지원하지 않습니다' 그것은 JS에서 변수를 선언하는 것을 기억하지 못하는 것입니다.

는 변경 :

banners = $$('.banner').sort(function (a,b){ 
    _a = parseInt(a.style.zIndex); 
    _b = parseInt(b.style.zIndex); 
    return _a < _b ? 1 : _a > _b ? -1 : 0; 
    }); 

에 :

var banners = $$('.banner').sort(function (a,b){ 
    _a = parseInt(a.style.zIndex); 
    _b = parseInt(b.style.zIndex); 
    return _a < _b ? 1 : _a > _b ? -1 : 0; 
    }); 

작품 잘.

관련 문제