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 trialDavid MacDonald
919 Pointsin script.js nothing is appearing when i use preview. How can i get the alert and header to appear?
I have the index.html file. Preview opens to port80 instead of web. Nothing appears after i enter the statement and command.
3 Answers
Jeff Wilton
16,646 PointsThere are three things to note, so lets take a look one at a time.
First, your index.html file should load the scripts.js file:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css">
<title>JavaScript Basics</title>
</head>
<body>
<div class="container">
<script src="scripts.js"></script>
</div>
</body>
</html>
Second, your scripts.js file should have an alert statement and a document.write statement:
scripts.js
alert("Hello from Treehouse!");
document.write("<h1>Welcome to Javascript Basics</h1>");
Third, when you open the preview window, it should go to port 80 with a URL something like this: http://port-80-i0up09r7h4.treehouse-app.com/
(this URL is unique to me, so use whatever URL opens when you click preview in your workspaces.
If you do all of the above and you still don't see the alert in the preview window, then try doing a hard refresh (Ctrl+Shift+R in Firefox or Chrome) or clear your browser cache.
Hope this helps!
Tre Dudman
10,575 PointsCtrl+Shift+R did the trick, thanks heaps!
Jay Reyes
Python Web Development Techdegree Student 15,937 PointsAlso, make sure you disable any AdBlocks you may have running - this is for future readers :)