【问题标题】:Jquery doesn't load in firefox and internet explorerJquery 无法在 Firefox 和 Internet Explorer 中加载
【发布时间】:2012-11-23 17:31:03
【问题描述】:

我托管了一个网站,当我在 google chrome 上打开它时一切正常,但在 Firefox 和 Internet Explorer 中,javascript 无法加载。

这是代码:

 <!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>
    <title>Me gustas cuando callas | ...es nombre de BLOG</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Language" content="es" />
    <meta name="description" content="Me gustas cuando callas es un proyecto nacido de la ilusión común de un grupo de personas de distintas edades, sexos y lugares del mundo, personas diferentes  a quienes la casualidad o tal vez el destino reunió en un mismo lugar." />
    <meta name="author" content="gresking@gmail.com" />
    <meta name="keywords" content="me, gusta, cuando, callas" />
    <meta name="robots" content="all" />
    <link href="css/reset.css" rel="stylesheet" type="text/css"/>
    <link href="css/layout.css" rel="stylesheet" type="text/css"/>
    <link href="css/ui/jquery.css" rel="stylesheet" type="text/css"/>
    <link rel="shortcut icon" type="image/x-icon" href="css/img/favicon.ico" />
    <script language="javascript" type="text/javascript" src="js/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="js/cufon.js"></script>
    <script language="javascript" type="text/javascript" src="js/fonts/caviardreams.js"></script>
    <script language="javascript" type="text/javascript" src="js/plugins.js"></script>
    <script language="javascript" type="text/javascript" src="js/main.js"></script>
</head>
<body>CONTENT</body></html>

我意识到它一定是 jquery,因为我包含了一个 alert("test");它可以工作,但都在 $(document).ready(function(){...});没有。

帮助PLS! :(

【问题讨论】:

  • 查看开发者工具,找到文件了吗?
  • 做 jQuery(document).ready();工作?如果你正在加载 jQuery 并且 $() 不起作用,你可能与另一个库发生冲突,并且 jQuery 进入了无冲突模式。
  • 我没有其他库,文件已创建。
  • 提供您页面的链接,我们可以为您提供更多信息。另外,我建议使用绝对路径,并且我建议使用 Google 的 CDN for jQuery。

标签: jquery internet-explorer firefox


【解决方案1】:

如果你在 FF 或 IE 中输入,你会看到 jquery js 文件吗?

http://<yoursite_URL>/js/jquery.js

也试试这个:

<script language="javascript" type="text/javascript" src="/js/jquery.js"></script>

您也可以尝试使用外部 jquery 库,看看是否有任何不同:

这可能是一个更好的选择,除非您在 jquery 中有自定义代码 :)

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.min.js" type="text/javascript"></script>

【讨论】:

    【解决方案2】:

    如果您在启用了 firebug 的 Firefox(我用 Google 搜索过)中加载页面,那么您会在文件 js/plugins.js 中收到错误:

    flashver.split 不是函数

    我不确定那行代码在做什么,但 flashVer 在开始时设置为 -1,我猜它应该设置为字符串,但出于某种原因不是。

    【讨论】:

      【解决方案3】:

      几种可能性:

      1) 代码包含在document.ready 中。页面是否已完全加载完毕?

      可能是图像损坏、api 调用超时或某些其他资源导致页面无法在一个浏览器中完全加载,而在其他浏览器中它会在一定时间内切断调用。 编辑

      我查看了chrome的开发者控制台,有几张图片没有加载

      ui-bg_highlight-soft_100_f6f6f6_1x100.png Failed to load resource: the server responded with a status of 404 (Not Found)

      我打赌其他浏览器不会因此触发ready

      2) 有时浏览器会解释和修复如下的 url 问题:

      /js/jsfile.js
      http://www.mysite.com//js/jsfile.js
      

      js/jsfile.js
      http://www.mysite.comjs/jsfile.js
      

      当这些被包含为相对链接地址时。也许有一个 url 错误,一个浏览器为您修复它,而另一个浏览器正确解释它?

      3) 另一种可能是您的其他 js 文件之一与 jQuery 冲突,并且 jQuery 进入无冲突模式导致 $() 不起作用,而是使用 jQuery()

      【讨论】:

      • 这是 URL,我已经尝试了你写的所有内容:/ [link}megustascuandocallas.com 如果你点击顶部的“crear cuenta”,它会打开一个模态框 jquery 加载。
      • 这是因为我使用了保留名称“var class”
      【解决方案4】:

      这是因为我使用了保留名称“var class”

      【讨论】:

        猜你喜欢
        • 2015-01-20
        • 2014-03-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多