开发者

jQuery Loads in Chrome but Not Firefox, why?

I'm using Django and I have an HTML file, with this line in the head tag:

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

This works fine 开发者_JAVA百科in Chrome, but it seems to have no effect in Firefox 3.6.18. (When I type in $ or jQuery in the Firefox console, I get an error, whereas Chrome just shows it correctly.) The rest of my scripts can't load because of this.

I tried strace, and it seems like the file is, in fact, loaded.

What could be causing this?


More info:

I can't post a lot of the HTML, but some relevant parts:

My HTML file (Django templates):

{% extends "my_base.html" %}
{% load stuff %}
{% block head %}
  {{ block.super }}
  <script type="text/javascript" src="/media/jquery_listbox/js/jquery-min.js"></script>
  <script type="text/javascript" src="/media/jquery_listbox/js/ui.core-min.js"></script>
  <script type="text/javascript" src="/media/jquery_listbox/js/ui.dropdownchecklist-min.js"></script>
  <link rel="stylesheet" type="text/css" href="/media/jquery_listbox/css/ui.dropdownchecklist.css" />
{% endblock %}

my_base.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="default.css"/>
    {% block head %}{% endblock %}
  </head>
  ...
</html>


It's hard to tell without seeing the rest of your HTML. With Firebug installed, you can check the Net tab to make sure the jQuery file is requested and returned correctly in Firefox. Or replace the src with Google's hosted jQuery which is https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js - if that works then you know it's a location problem, not a code problem.


First I'd clear the browser cache. Secondly I'd change that local js file to always pull from the Google CDN

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js" type="text/javascript"></script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜