10

Internet Explorer 8 を除く他のすべてのブラウザーで動作するように見える diapo スライダーを使用しています。

デバッグ モードで ie8 を実行すると、次のエラーが表示されます。

SCRIPT438: オブジェクトはプロパティまたはメソッド「getElementsByClassName」prototype.js、5988 行目の文字 5 をサポートしていません

return function(className, parentElement) {
    return $(parentElement || document.body).getElementsByClassName(className);
  };

SCRIPT438: オブジェクトはプロパティまたはメソッド 'fireEvent' をサポートしていません。prototype.js、行 5736 文字 7

if (document.createEvent)
      element.dispatchEvent(event);
    else
      element.fireEvent(event.eventType, event);

    return Event.extend(event);

このスライダーを magento プラットフォームで実行していますが、プロトタイプ スクリプトに問題があるようです。使用しているプロトタイプのバージョンは 1.7 であるため、スクリプトの更新による修正の可能性は除外されます。

注: ie9 では表示に問題はありませんが、次のエラーが表示されます。

SCRIPT438: オブジェクトはプロパティまたはメソッド 'dispatchEvent' をサポートしていませんprototype.js、行 5734 文字 7

if (document.createEvent)
      element.dispatchEvent(event);
    else
      element.fireEvent(event.eventType, event);

    return Event.extend(event);

これらは、diapo スライダーが機能するために必要なスクリプトであり、ヘッダーに script タグを付けてロードされます。よくわかりませんが、これらのスクリプトのいくつかが既存のスクリプトと競合している可能性があります。

<script type='text/javascript' src='http://www.pixedelic.com/plugins/diapo/scripts/jquery.min.js'></script>
<script type='text/javascript' src='http://www.pixedelic.com/plugins/diapo/jquery.mobile-1.0rc2.customized.min.js'></script>
<script type='text/javascript' src='http://www.pixedelic.com/plugins/diapo/jquery.easing.1.3.js'></script>
<script type='text/javascript' src='http://www.pixedelic.com/plugins/diapo/jquery.hoverIntent.minified.js'></script>
<script type='text/javascript' src='http://www.pixedelic.com/plugins/diapo/scripts/diapo.js'></script>
4

1 に答える 1

18

IE8はをサポートしていませgetElementsByClassName。ただし、サポートしquerySelectorAllます。したがって、を使用してポリフィルを作成することをお勧めしquerySelectorAllます。

document.getElementsByClassName('foo')

になる

document.querySelectorAll('.foo'); // Prefixed dot.

Prototype.jsは、とを支持しての使用を非推奨にしていることに注意しくださいgetElementsByClassName$$Element#select

IE8のクイックフィックス:

<!--[if IE 8]><script>
document.getElementsByClassName = 
Element.prototype.getElementsByClassName = function(class_names) {
    // Turn input in a string, prefix space for later space-dot substitution
    class_names = (' ' + class_names)
        // Escape special characters
        .replace(/[~!@$%^&*()_+\-=,./';:"?><[\]{}|`#]/g, '\\$&')
        // Normalize whitespace, right-trim
        .replace(/\s*(\s|$)/g, '$1')
        // Replace spaces with dots for querySelectorAll
        .replace(/\s/g, '.');
    return this.querySelectorAll(class_names);
};
</script><![endif]-->

ノート:

  • 複数のクラス名をサポートします。
  • ''空の( )クラス名はサポートしていません。必要に応じて、これらのサポートを追加するのは簡単です。

デモ: http: //jsfiddle.net/HL4FL/21/

于 2012-05-07T15:09:26.170 に答える