Ben H
Ben H

Reputation: 3236

Why doesn't this external JavaScript load?

I've been futzing with this for hours trying to figure out why codemirror.js won't load in any browser other than Firefox. Any ideas?

index.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" xml:lang="en"> 
<head>
    <title></title> 
    <script src="CodeMirror/js/codemirror.js"></script> 

    <link href="Styles/Style.css" rel="stylesheet" type="text/css" />
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /> 

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> 
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 

    <script type="text/javascript"> 
        $(document).ready(function () { $('#container-1').tabs(); });
    </script> 
    <style type="text/css"> /* (some css) */ </style>
</head><body>
<!-- (some stuff) -->
</body></html>

CodeMirror/js/codemirror.js

alert("LOL");

Upvotes: 0

Views: 1855

Answers (1)

Guffa
Guffa

Reputation: 700342

I tried the code in Firefox 3.6.3, Internet Explorer 8, Opera 10.53 and Safari 4.0.5, and it works just fine.

Note that the address to the script is relative, so if your page is at www.mydomain.com/content/pages/page.html, it will load the script from www.mydomain.com/content/pages/CodeMirror/js/codemirror.js, not www.mydomain.com/CodeMirror/js/codemirror.js.

One thing that you can improve is to add the type attribute to the tag:

<script src="CodeMirror/js/codemirror.js" type="text/javascript"></script>

Upvotes: 3

Related Questions