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 trialHanis Mekić
174 PointsI can not link the js file to the html. It won't show the popup message. When i write it in the html directly it works.
please help
5 Answers
Conan Ngan
Full Stack JavaScript Techdegree Student 6,967 PointsI found that /js/script.js didn't link the file correctly if index is in js also. So just link it as script.js
josephweiss2
8,022 Pointstry to link the js file at the end of the html right before the </body> tag, it should work
Hanis Mekić
174 Pointstried everything, even i tried with the basic html example but still doesn't work.
josephweiss2
8,022 Pointscan you share the html and the js you want to link?
Safae Chkirate
6,113 PointsHello, This message is for people who have the same problem as you. Because I believe that since August 2022, your problem has been resolved.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Basics</title>
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<main>
<h1>Hello, JavaScript!</h1>
</main>
<script src="js/preview.js"></script>
</body>
</html>
You must pay close attention to the path of your JavaScript script. If it is stored (as in the lesson) in a folder called "js," you need to go up one level in the hierarchy.
Alternatively, if it is stored at the same level as your HTML index file, use the example below.
<script src="preview.js"></script>
Gabriela Miranda
435 Points@melanieelanduenas Tks very much. Now that you said ran out like supossed to. <script src="script.js"></script>
melanieelanduenas
Full Stack JavaScript Techdegree Student 528 Pointsmelanieelanduenas
Full Stack JavaScript Techdegree Student 528 Pointsthis worked for me, take out JS/, so it should be "<script src="script.js"></script>". Im happy im starting with a free trial I just started these courses and I don't get why there is so many issues in the teachings and fellow students are the ones finding the answers to these problems. This comment from 2 years ago helped me, yet there isnt an edit in the video for a known issue?