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 trialZander Curtis
10,634 PointsWhere is the place to add the script.js code?
Don't I have to write the document.write() code in a .js file?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
</body>
<div class="container">
<script> src="scripts.js">"Welcome to my site"</script>
</div>
</html>
4 Answers
Bart Bruneel
27,212 PointsHello Zander,
The script is on the right place in the html-document, but you have to place the src-attribute inside the script-tag. Like this:
<script src='scripts.js'></script>
Zander Curtis
10,634 PointsThanks Bart,
Once I watched the next video I figured out it was supposed to be
<script> document.write("Welcome to my site"); </script>
That gave the right answer. Would your script work as well?
ZC
Bart Bruneel
27,212 PointsYes, if you would place
document.write("Welcome to my site");
into a separate .js-file. So you can place it directly into the html-file by placing it in between the script-tags or you can place it in a separate .js-file by adding a src referring to the .js-file inside the script-tag.
Zander Curtis
10,634 PointsThanks Bart for you help and your contribution to the Treehouse Community!