简体   繁体   English

如何在Eclipse中添加JS资源?

[英]How do you add JS resources in eclipse?

I have created a javascript file on my computer, and I wanted to put it in a web page. 我已经在计算机上创建了一个javascript文件,并希望将其放在网页中。 I used this html file to hold the code, with an src to load the processing js library that I had based my script on: 我使用此html文件保存代码,并使用src加载基于脚本的处理js库:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="ISO-8859-1">
            <title>Processing JS</title>
        </head>
        <body>
            <script src = "C:/Users/RandomNameAlphabetically:-)/Desktop/processing.js></script>
        </body>
    <html>

When I loaded this page in Google Chrome, it had an error that it could not load processing.js. 当我在Google Chrome浏览器中加载此页面时,出现了无法加载processing.js的错误。 Could anyone help me solve this problem? 谁能帮我解决这个问题?

Don't store your JavaScript file on your desktop. 不要将JavaScript文件存储在桌面上。 Put it in the same directory (or a child directory) as your HTML file and link to it as: 将其放在与HTML文件相同的目录(或子目录)中,并链接为:

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

So it sounds like this is an Eclipse question. 听起来这是一个Eclipse问题。

First, Eclipse creates a workspace. 首先,Eclipse创建一个工作区。 Eclipse's default workspace on Windows is something like C:\\Users\\[userID]\\Eclipse\\ Windows上Eclipse的默认工作区类似于C:\\ Users \\ [userID] \\ Eclipse \\

Then you create projects of code in that workspace. 然后,您在该工作区中创建代码项目。 You can have many projects in one workspace. 一个工作空间中可以有多个项目。

It is easy for you to create multiple workspaces, too. 您也很容易创建多个工作区。 Projects in one workspace will not be visible in another. 一个工作区中的项目将在另一工作区中不可见。

You need to open up Windows Explorer and copy your JavaScript file from the desktop and paste it into the project in the workspace to be able to see and use it in your code. 您需要打开Windows资源管理器并从桌面复制JavaScript文件,然后将其粘贴到工作区中的项目中,以便能够在代码中查看和使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM