jQuery OEmbed 插件 - 错误 : Object doesn't support this property or method

标签 jquery internet-explorer-7 plugins

我目前正在使用以下 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 here .

有趣的是,这个错误不会出现在 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"
};

注意“replace”后面的逗号

工作演示:http://jsbin.com/oxitu

关于jQuery OEmbed 插件 - 错误 : Object doesn't support this property or method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1627790/

相关文章:

linux - 我可以从 Nagios-Plugins 包中编译单个 .c 文件吗?

jquery - 在 jquery 对话框中加载表单会导致空的 serialize()

css - CSS 和 Internet Explorer 7 的神秘问题

CSS 下拉菜单令人沮丧的问题

css - IE7 导航栏边距和填充方式关闭

java - Maven:无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile

javascript - 如何将我的 jQuery 插件应用到动态创建的元素

javascript - 我们如何在多个选项卡(页面)中使用相同的状态?

javascript - jQuery Toggle 第二次无法正常工作

javascript - 我自己的工具提示中的 href