【问题标题】:ColorBox error in IE "Object doesn't support this property or method"IE 中的 ColorBox 错误“对象不支持此属性或方法”
【发布时间】:2013-04-03 18:02:23
【问题描述】:

我正在尝试使用以下代码将 jquery 颜色框添加到我的网页:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <link rel="stylesheet" href="colorbox.css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.colorbox-min.js"></script>
</head>
<body>
    <script type="text/javascript">
        $(function ()
        {
            $(".popup")
            .colorbox({iframe:true, innerWidth:695, innerHeight:340, overlayClose:false });

        })
    </script>
    <a class='popup' href='http://www.bbc.co.uk'>bbc.co.uk</a>
</body>

它适用于 firefox 和 chrome。但是当我在 IE7 中运行它时,出现以下错误:

对象不支持该属性或方法

任何帮助都会很棒。

【问题讨论】:

  • JavaScript 文件是否加载正确?
  • 是的,所有 javascript 文件都已正确加载
  • 你加载的是什么版本的jquery?

标签: javascript jquery internet-explorer colorbox


【解决方案1】:

您很可能有一个无效的&lt;script&gt; 标签,或者包含设置为text/javascript 以外的类型属性的标签。

如果没有看到那部分代码,我们无法确切地找出问题所在。

更多信息

脚本标签必须有一个结束 &lt;/script&gt;&lt;script /&gt; 不适用于所有浏览器。

此外,type 属性必须为 text/javascript 或不存在。如果是application/javascript,某些版本的IE是不会执行的。

【讨论】:

  • 我所有的
  • 它周围的其他标签是否无效?如果它与标签无关,那么一个浏览器没有理由对此感到窒息。除非发生了更多您没有通知我们的错误,否则这不会是 javascript 错误。
  • 我很快就用弹窗做了一个空白网页,仍然有ie的问题
  • 你能把它的来源贴到我们能看到的地方吗,比如jsfiddle.com?
  • 您的代码对我有用:jsfiddle.net/9XJAG/2 但是由于 mimetype 不匹配,我不得不直接包含 css 和 js。您的服务器是否返回具有正确 mimetype 的文件?
猜你喜欢
  • 2011-04-27
  • 2011-02-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多