0

I am new to javascript and am trying to get this to work. When I link to my external .js file from my HTML it doesn't work, but when I enter the script directly in the HTML file, it works. I am sure that the src link I have given in the HTML is correct. I have checked it multiple times. I have both my linked .js files in the same folder as my HTML file.

This is the index.html file:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>Radar chart</title>
    <script src="http://d3js.org/d3.v3.min.js"></script>
    <script src="RadarChart.js"></script>
    <style>
        body {
          overflow: hidden;
          margin: 0;
          font-size: 14px;
          font-family: "Helvetica Neue", Helvetica;
        }

        #chart {
          position: absolute;
          top: 50px;
          left: 100px;
        }   
    </style>
  </head>
  <body>
    <div id="body">
      <div id="chart"></div>
    </div>

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

  </body>
</html>

The error I am getting is as follows:

   file:///home/******/*****/Tempelates/Test/script.js Failed to load resource: net::ERR_FILE_NOT_FOUND

I am using Linux. I have already looked at the following questions, but they could not help me.

Javascript files not working when linked, but work internally?

javascript file not working when linked from HTML

Javascript not working with HTML external link

I have been breaking my head over this. Help would be much appreciated. Thanks.

EDIT The code works fine in Windows but not in linux. I am even more confused now.

Community
  • 1
  • 1
user13987
  • 3
  • 7

4 Answers4

0

Are you using Google Chrome? I fixed my problem with the solution from here:
Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found

I think you have already solved this by now, but for what matters I've had the same problem on Google chrome and I did the following to fix it:

  1. Choose Customize and Control Google Chrome (the button in the up, right corner)
  2. Choose Settings
  3. Extensions
  4. Unmark all the extensions there. (they should show as Enable instead of Enabled) Regards,
Community
  • 1
  • 1
Douglas K.
  • 921
  • 1
  • 7
  • 6
0

Since you're using Linux, make sure you have read/write permission to all the files and folders you're working with. That can cause these types of problems.

Makan
  • 547
  • 6
  • 8
  • I checked that I have all the permissions. – user13987 Mar 30 '15 at 20:59
  • If you still have not solved this issue and you really have to, I suggest that you post your script.js and RadarChart.js files here or make a jsfiddle or somehting. There might be something wrong within the code that is causing the problem. That way we can play with the full code to see what is causing the issue. – Makan Mar 31 '15 at 02:42
0

you want to check if the script.js is in the same folder as the html is , if not then you need to use the path to get to that folder and then reference the javascript file.

chetank
  • 392
  • 3
  • 17
0

The answer is by OP. It was an extremely stupid mistake and I had stored the name of "script.js" incorrectly. I had stored it as "srcipt.js". I had made separate files in windows and copied the code there, instead of copying the files, that is why it worked there.

user13987
  • 3
  • 7