Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTeacher Russell
16,873 PointsCan't link to the JS file
I don't want to use workspace, because I find it impractical in some ways, and I want to be sure I can actually do these things in reality, which I can't. I have the script.js file, and I have the html saved as text and html files. The html runs, but it isn't linking to the js file, so I don't get the "back for more" message. How can I learn to link js to html for real? I won't be using workspace when I'm designing a web page. How do I get this to work in real life?
2 Answers
stjarnan
Front End Web Development Techdegree Graduate 56,488 Points<script src="pathToYourFile/file.js"></script>
I hope that helps
Jonas
stjarnan
Front End Web Development Techdegree Graduate 56,488 PointsI always use my own text editor myself, so using your own is ok, it all comes down to personal preference :)
Let us know what you need help with and what's confusing you and we will try to help you get untangled! Most people get confused in the beginning, being overwhelmed is also a normal feeling when starting out. You can do this!
Jonas
Erik L
Full Stack JavaScript Techdegree Graduate 19,470 Points<script src="scripts.js"></script>
this is my code and it's not linking with the html page, I am using the atom text editor
miikis
44,957 PointsHi Russell,
It's okay, brother-man; don't quit before you get started! Everything is difficult in the beginning. Just stick it out ;)
I noticed you said you have the HTML saved as html and text files. If I'm interpreting that correctly, and you do indeed have two different type of files housing your HTML — a .html and a .txt file — then there's no need for that; you just need a file that ends in .html.
Also, like stjarnan hinted, your HTML file only knows about your JavaScript file if you include the file's path-name inside a <script/> tag. You'll want to make sure you get that file's path-name correct; it won't work if there's a typo.
If that doesn't help, feel free to post your code. If you post the contents of your HTML, and tell us the structure of the directory that it's in, we'll solve this problem for ya real quick.
Xayaseth Boudsady
21,951 PointsXayaseth Boudsady
21,951 PointsWhat I do is download the "Project Files", then I open them up in Microsoft: Visual Studio Code. Then I all all my index.html files on a Chrome Browser. I have the Editor and browser side-by-side. This is a faster process for me than using Workspace, plus I can open up the developer tool and look at the console to see where the error in my code is taking place.