最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - 404 error loading a .js file from html script - Stack Overflow

programmeradmin6浏览0评论

I'm new in using javascript and html.

I've been following a tutorial that involves loading files from the Paperjs code library. I'm trying to load a js file that contains functions and objects for placing images on web pages.

Whenever I attempt to load the "paper-full.js" file, I get a 404 error in the Console, despite the "paper-full.js" file being in the same location as the "index.html" file that's calling for it. The preview page also has the localhost IP address as the page's title, rather than the file name.

The goal for this part of the tutorial is just to place an image at [0,0] on the preview page.

Any ideas on where the mistake could be will be greatly appreciated.

folder containing the paper-full and index files

preview page error for index.html

Here is the index.html file

  <!DOCTYPE html>
<html>
    <head>
        <!-- Imports the Paper.js library -->
        <script type="text/javascript" src="js/paper-full.js">
        </script>

        <!-- Connects Paper.js with the HTML canvas -->
        <script type="text/paperscript" src="js/rocket.js" canvas="canvas"></script>        
    </head>
    <body>
        <canvas id="canvas" width="800" height="800"></canvas>
    </body>
</html>

I'm new in using javascript and html.

I've been following a tutorial that involves loading files from the Paperjs code library. I'm trying to load a js file that contains functions and objects for placing images on web pages.

Whenever I attempt to load the "paper-full.js" file, I get a 404 error in the Console, despite the "paper-full.js" file being in the same location as the "index.html" file that's calling for it. The preview page also has the localhost IP address as the page's title, rather than the file name.

The goal for this part of the tutorial is just to place an image at [0,0] on the preview page.

Any ideas on where the mistake could be will be greatly appreciated.

folder containing the paper-full and index files

preview page error for index.html

Here is the index.html file

  <!DOCTYPE html>
<html>
    <head>
        <!-- Imports the Paper.js library -->
        <script type="text/javascript" src="js/paper-full.js">
        </script>

        <!-- Connects Paper.js with the HTML canvas -->
        <script type="text/paperscript" src="js/rocket.js" canvas="canvas"></script>        
    </head>
    <body>
        <canvas id="canvas" width="800" height="800"></canvas>
    </body>
</html>
Share Improve this question edited Jun 6, 2018 at 4:44 AbdulAhmad Matin 1,1461 gold badge18 silver badges29 bronze badges asked Jun 6, 2018 at 3:46 Artist codeArtist code 231 gold badge1 silver badge2 bronze badges 2
  • You're trying to load js/paper-full.js. That should be paper-full.js. As for the title, you can set it using a <title> tag in the <head> section. – Robby Cornelissen Commented Jun 6, 2018 at 3:50
  • 1 Related: stackoverflow./questions/2005079/absolute-vs-relative-urls – faintsignal Commented Jun 6, 2018 at 3:54
Add a ment  | 

1 Answer 1

Reset to default 4

Looking at your project structure you have your paper-full.js and rocket.js files alongside your index.html file, but you are looking for them inside a /js/ folder that doesn't exist.

Try this, noting how I have changed js/etc to ./etc, meaning it will look for it's neighboring file.

<!DOCTYPE html>
<html>
    <head>
        <!-- Imports the Paper.js library -->
        <script type="text/javascript" src="./paper-full.js">
        </script>

        <!-- Connects Paper.js with the HTML canvas -->
        <script type="text/paperscript" src="./rocket.js" canvas="canvas"></script>        
    </head>
    <body>
        <canvas id="canvas" width="800" height="800"></canvas>
    </body>
</html>
发布评论

评论列表(0)

  1. 暂无评论