【问题标题】:'jQuery' is not defined when importing simplemodal导入 simplemodal 时未定义“jQuery”
【发布时间】:2011-04-08 08:13:38
【问题描述】:

这只发生在 IE6 中。使用以下代码,我得到错误'jQuery' is not defined on line 9 char 1。删除 simplemodal 行时没有错误。我尝试设置 type="text/javascript" charset="utf-8" 但它仍然不起作用。有什么想法吗?

<html>
    <head>
        <script language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
        <script language="Javascript" src="scripts/jquery.simplemodal.1.4.1.min.js"></script>
        <script type="text/javascript">
            if (typeof jQuery == 'undefined'){
                document.write(unescape("%3Cscript type='text/javascript' charset='utf-8' src='scripts/jquery-1.4.4.min.js' type='text/javascript'%3E%3C/script%3E"));
            }
        </script>
    </head>
    <body>
        test
    </body>
</html>

【问题讨论】:

  • 为了好玩,把https改成http会怎样?有什么区别吗?
  • 有什么理由这样做?
  • 去掉 s 无济于事。
  • 你有未定义的检查,但你是否真的尝试过使用 jQuery 对象(有和没有 simplemodal 插件脚本行)。例如。做好文件准备和警觉。这行得通吗?
  • 警报在 IE8 中有效。不在IE6中。在带有简单模式的 IE6 中,我们得到了同样的错误。在没有 simplemodal 行的 IE6 中,我得到“预期对象”。

标签: jquery html internet-explorer-6 simplemodal


【解决方案1】:

如果你写 type="application/javascript" IE 不会读取标签内的代码。你必须使用文本/javascript

【讨论】:

    【解决方案2】:

    尝试改变

    <script language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    

    <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-latest.js"></script>
    

    【讨论】:

    • 是的,我试过了。它不是导致问题的 jQuery 行。它是一种简单的模式。
    • 使用 jquery-latest 可能会导致未来的问题,不完全推荐,imo。
    【解决方案3】:

    将 SimpleModal 的加载移至未定义检查之后。

    【讨论】:

      猜你喜欢
      • 2016-05-23
      • 2016-06-24
      • 2017-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-29
      相关资源
      最近更新 更多