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 trial

JavaScript JavaScript Basics Hello, JavaScript! Add JavaScript to HTML

I'm not getting the same view after creating script.js and linking it to index.htm. I see a Index of page with 2 items.

These 2 items are css and js. I cannot get the page to display anything else.

2,573 Points

This happened to me because my index.html file was inside the CSS folder (for some reason). Is the index.html file in a folder? I believe this is what causes the issue. It needs to be in JavaScript Basics main folder on its own. I hope this helps! :)

2 Answers

Im posting this for anyone to see. This was 1 issue I was getting among the other issue of not being able to get the alert boxes to pop up.

1) Get Chrome. Just stop, use the tools like you would for any other class. Get chrome. 2) This next part is crucial. Step by step follow along. Before starting the video, underneath the video is the section with resources. There is a tab called workspaces, click on it. Now, do not let it create the workspace for you. I'm not sure why, but this is what I had to do after reading all the questions and answers in this section and spending an hour to get it to work. It will say something like " you need to create a workspace..." click on bold letter "create workspace". a window will pop up and say launch workspace. STOP! do not. Instead click on the bottom link called "Launch Different Workspace". Then click on create new workspace. 3) from here, you now want to do the following: name for workspace is JavaScript Basics. Environment type leave as any environment. Lastly, for the template choose Add Javascript to HTML. There is a dropdown with a lot of others but, this is the one you want to load the preview js and index file. Now click launch it.

4) What this does from what I'm thinking is, it already sets the index file to be in the main parent folder called Javascript Basics. Everytime I tried to manually do it, for some reason it would not recognize even after saving. Meaning, it showed that index.html was in the parent folder and not in CSS but still, using the created workspace form the prompts did not work. This is the only way i got it to work.

to verify beofre starting , just click the eye icon and you should get the new screen that is blue and says "Hello Javascript" just like the instructor.

If you get this far and something does not work, at this point then it can only be your syntax grammar. Double check that alert is spelled correctly, that src is not scr and or another common one is proper spacing with the script tag.

Hope this helps.

NOTE: to get the workspace to appear as a tab in chrome, Right click on the top of the page that pops up. Look down the list for Show as a tab. The page will reload into a new browser page. Then simple put your mouse pointer over the top of the tab. Left click and hold to grab the tab then simply drop it into the browser with the video. Now you have it all in one browser with two tabs.

It did the same for me But it worked once I typed the js syntax within the html file using the <script> tag Must be something with the directories on workspaces