0

I have been struggling with a problem that drives me crazy. My Chrome browser won't load my jquery file specified in my script tag. If i look in developer tools it doesn't even load. If i try my html file in Safari I can se it load in web inspector and i can see a log in my console. For chrome i see no errors. If I view source I can see my html (I am not browsing the wrong file or a cached file). I've created a small test html file with the same problem. My simple test code looks like this:

<!doctype html>
<html>
<head>
    <title>testing</title>
    <script src="file:///Users/user/OneDrive/Document/test/jquery-2.1.4.min.js"></script>
</head>

<body>
    <h1>
        H1
    </h1>   
    <script>
        $(document).ready(function () {
            console.log('test');
        });
    </script>           
</body>

EDIT! Well this is a bit embarrassing. Even though you should not code like this it should work. But I just learned that disabling javascript in chrome and chrome developer tools are two different things. I did only check that javascript was enabled in chromes settings.

Time for a break and some coffee..

Deltoide
  • 1
  • 2
  • 2
    By default, chrome doesn't allow to load local resource BUT you should have error in console then. So not sure how do you debug it – A. Wolff Nov 29 '15 at 16:55
  • There are many restrictions on accessing resources with a `file://` url. [See this question](http://stackoverflow.com/questions/4270999/google-chrome-allow-file-access-from-files-disabled-for-chrome-beta-8) for details. – Kenney Nov 29 '15 at 16:55
  • @Deltoide You can't reference the jquery file this way. THINK ABOUT IT! You are going to a website which is reading the local files in your computer without your permission. – Tony Wu Nov 29 '15 at 17:08
  • @Deltoide You are only allowed to use relative path `/Script/xxxx.js` or absolute path `http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js`. – Tony Wu Nov 29 '15 at 17:12

1 Answers1

0

Make sure javascript is enabled. Chrome has separate settings for this in Chrome and in Chromes developer tools, check both. More about this problem here

Community
  • 1
  • 1
Deltoide
  • 1
  • 2