2011-10-27 5 views
3

Firebugのコンソールをクロムないエラーをスロー:IEでIEでjquery.jsとモジラでエラーなく

uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://localhost:30326/Scripts/jquery-1.6.4.js :: anonymous :: line 6570" data: no]

エラーが以下与えられるライン6570に来ている:

if ((computedStyle = defaultView.getComputedStyle(elem, null))) { 

エラーが

私はjavascriptやjqueryののデバッグについて全く分からない「そのようなインタフェースがサポートされていない」されています...

はEDIT

のTx ...、Arnab

を、これが起こる可能性がなぜ任意のアイデアを、このエラーを見た誰もが持っている: にも何か他のものを見つけました。これはjqueryのメソッド..です

if (document.defaultView && document.defaultView.getComputedStyle) { 

     getComputedStyle = function (elem, name) {   

     var ret, defaultView, computedStyle; 
       name = name.replace(rupper, "-$1").toLowerCase(); 
       if (!(defaultView = elem.ownerDocument.defaultView)) 

    {    return undefined;  

     } 
       if ((computedStyle = defaultView.getComputedStyle(elem, null))) {  

// は、[エラーがelemは値を投げます場所です「」です]

   ret = computedStyle.getPropertyValue(name); 
          //    **[The value of name is opacity]** 

      if (ret === "" && !jQuery.contains(elem.ownerDocument.documentElement, elem)) {   

       ret = jQuery.style(elem, name);   

      }  

     } 
       return ret; 

     }; 

     } 

しかし、私はその方法から見つけることができませんでした

if (elem.wholeText == " " && name == "opacity") { 
       return "1"; 
      } 
     if ((computedStyle = defaultView.getComputedStyle(elem, null))) 
:鉱山の、jqueryの中にこのメソッドが呼び出され、誰でもスクリプトがページ

ソリューションで焼成されているJS順序を見つける方法を知っています

場合は基本的に((computedStyle = defaultView.getComputedStyle(elemは、NULL)))ライン 上記のコードを追加する方法を示すためにジャスティンに

おかげで....

+3

*あなたのコードの関連する行を投稿してください。このためにjsfiddleを使用することができます。 –

+0

txは、jqueryが呼び出されている元を見つけようとします。 – Arnab

+0

それは私に起こりました。getComputedStyleコールの周りにtry-catchを置いて、これを得ました:[注意:ELEMはNULLではありません(NS_ERROR_FAILURE) "nsresult:" 0x80004005(NS_ERROR_FAILURE) "場所:" JSフレーム:: http:// localhost:35973/scripts /jquery-1.9.1.js :: getStyles :: line 6927 "data:no" getStyles(elem = undefined)jquery-1.9.1.js(行6929) curCSS(elem = Object {element = g.highcharts -series、renderer = {...}、attrSetters = {...}、more ...}、name = "Webk ..." – Bakhshi

答えて

0

はあなた、それは可能です」隠し要素のオフセットや位置を取得しようとしていますか?この種のエラーでいくつかの先例があるかもしれないように見えます:

http://bugs.jquery.com/ticket/2528

そのような場合、ここに助けるかもしれない回避策です:

http://siderite.blogspot.com/2009/07/jquery-firexof-error-could-not-convert.html

前述したように、それは使用しようとしているコードのサンプルを入手するのに非常に役立ちます。

ハッピーコーディング!

+0

私の場合、コードを表示するにはJustinに感謝します。 。 – Arnab

5

IE9では、スタイルを持たないDOMノード(テキストノードなど)でgetComputedStyleを実行すると「このようなインターフェイスはサポートされていません」というエラーがスローされます。私はDOMを歩いているときにこれに遭遇しました。

if (elem.nodeType === elem.ELEMENT_NODE) { 
    document.defaultView.getComputedStyle(elem, null); 
} 
0

私はhighchartsツールチップでの作業この問題に遭遇した:だからgetComputedStyleに要素を渡す前に、それはこのように、ノードタイプです確認してください。彼らはjqueryの1.9.1からのコードのこのビットに窒息した。

if (window.getComputedStyle) { 
    getStyles = function(elem) { 
     return window.getComputedStyle(elem, null); 
    } 
... 

は、それは私がそれをhighchartsに使用されているsvgElementの場合はnullに気づいたように、定義されているnodeTypeのためのチェックを追加することで、エラーを投げて停止しました。

getStyles = function(elem) { 
    if (elem && elem.nodeType) { 
     return window.getComputedStyle (elem, null); 
    } 
}