jQuery OEmbedプラグイン-エラー:オブジェクトはこのプロパティまたはメソッドをサポートしていません

StackOverflow https://stackoverflow.com/questions/1627790

質問

現在、jQueryプラグインjQuery OEmbedを使用しています。このプラグインは、FF、Chrome、およびSafariでうまく機能します。ただし、IE7で問題が発生しています。私は自分のコードを非常に骨抜きにしていますが、それでも次のエラーの原因がわからない:

Error: Object doesn't support this property or method.

エラーが参照している行は次のとおりです:

  $("#container").oembed("http://www.youtube.com/watch?v=nue4pvzuyOo");

これが私のHTMLです(これも非常に基本的なものです):

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <title>jquery-oembed explicit insert example</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>  
    <script type="text/javascript" src="oe.js"></script>
  </head>
  <body>
   <script type="text/javascript">
    $(document).ready(function() {
            $("#container").oembed("http://www.youtube.com/watch?v=nue4pvzuyOo");

    });
  </script>
 <div id="container"></div>
 </body>
 </html>

プラグインのjavascriptは、こちらにあります。

興味深いことに、このエラーはIE8では発生しません。IE7のみです。

このエラーの原因についての考えはありますか?

役に立ちましたか?

解決

JSLint は、他の問題の中でも、リンクしたプラグインコードがオブジェクトリテラル内に余分なコンマを持っていることを報告します。 。これを修正すると、IE7で修正されるようです。

修正:

// Plugin defaults
$.fn.oembed.defaults = {
    maxWidth: null,
    maxHeight: null,
            embedMethod: "replace", // "auto", "append", "fill"
};

変更:

// Plugin defaults
$.fn.oembed.defaults = {
    maxWidth: null,
    maxHeight: null,
            embedMethod: "replace" // "auto", "append", "fill"
};

&quot; replace&quot; の後のコンマに注意してください。

作業デモ: http://jsbin.com/oxitu

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top