Ошибка Javascript прототипа (только в IE) «Объект не поддерживает это свойство или метод» - PullRequest
1 голос
/ 01 августа 2010

Один из наших разработчиков вместе вращает баннер, и, хотя он отлично работает в NOT IE, IE выдает ошибку в строке 30 (помечена ниже как «***** ОШИБКА НА СЛЕДУЮЩЕЙ СТРОКЕ»). Могу ли я не сортировать $$ ('. Banner')?

Ошибка: 'Объект не поддерживает это свойство или метод'

Использование прототипа 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 Ответ

1 голос
/ 04 августа 2010

* Вздох *

После всего этого, я не помню, как объявлять переменные в 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;
  });

Работает нормально.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...