3

mootools を使用するスライダー ヘッダーのスクリプトは、IE7 と 9 では正常に動作しますが、8 ではエラーが発生します。他のすべてのブラウザーでも正常に動作します。

Line: 2148
Char: 3
Error: Invalid procedure call or argument
Code: 0
URL: (Path to mootools.svn.js)

コードは次のとおりです。

setStyle: function(property, value) {
    switch (property) {
        case 'opacity': 
            return this.setOpacity(parseFloat(value));
        case 'float': 
            property = (window.ie) ? 'styleFloat' : 'cssFloat';
    }
    property = property.camelCase();
    switch ($type(value)) {
        case 'number': 
            if (!['zIndex', 'zoom'].contains(property)) 
                value += 'px'; 
            break;
        case 'array': 
            value = 'rgb(' + value.join(',') + ')';
    }
    this.style[property] = value;
    return this;
},

行 2148 は次のとおりです。

this.style[property] = value;

私は何日も答えを探していましたが、JavaScript があまり得意ではないので、助けていただければ幸いです。

4

2 に答える 2

2

http://code.google.com/p/cnetjavascript/downloads/detail?name=mootools.svn.js&can=2&q=を使用していますか?

これは非推奨であり、ソースで参照を確認するとwindow.ie、次のスニペットのようになります。これを使用している場合は、サポートされている最新の JavaScript フレームワークへのアップグレードを検討する必要があります。

/*
Class: window
    Some properties are attached to the window object by the browser detection.

Properties:
    window.ie - will be set to true if the current browser is internet explorer (any).
    window.ie6 - will be set to true if the current browser is internet explorer 6.
    window.ie7 - will be set to true if the current browser is internet explorer 7.
    window.khtml - will be set to true if the current browser is Safari/Konqueror.
    window.gecko - will be set to true if the current browser is Mozilla/Gecko.
*/

if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.khtml = true;
else if (document.getBoxObjectFor != null) window.gecko = true;
于 2012-12-07T16:00:09.313 に答える
1

呼び出し後に例外が発生したthis.style[property] = value場合、それは無効な値の実際の問題である可能性があります-width: -5または'scroll:"none"'など。

これをデバッグして、それがどのようなプロパティと値であるかを確認し、上流でキャッチします-多くの場合、緩和/弾力性が原因です(たとえば、カスタム遷移が0の高さのFx.morph)。

値が無効になるのを防ぐことができない場合は、アニメーションの呼び出しまたはそれをトリガーするものの周りにtry/catchを貼り付けてください。

于 2012-12-07T23:25:29.460 に答える