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 trialChandni Chandihok
1,106 PointsCan't get my second alert to appear
INDEX CODE: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>JavaScript Basics</title> <script> alert("Here's another message from Treehouse"); </script> </head> <body> <div class="container"> <h1>Where to place your JavaScript code.</h1> </div> <script src="script.js"></script> </body> </html>
SCRIPT.JS CODE: alert("Hey, you're back for more?");
I can't seem to get the second alert that says "Hey you're back for more" to pop up?
Please help
Benjamin Barslev Nielsen
18,958 PointsThe code works fine for me. It is most likely that it doesn't find your script.js file. Is script.js placed in the same folder as the index.html? When running in the browser, do you see any errors in the console?
John Erickson
Full Stack JavaScript Techdegree Student 3,916 PointsI think I may have figured out your issue. In your HTML/head tag you have placed a script tag, but don't provide the src attribute. When watching the video go to time stamp 3:11:
<script src="scripts.js"></script>
This should correct your problem.
Chandni Chandihok
1,106 PointsI got it -->
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>JavaScript Basics</title> <script> alert("Here's another message from Treehouse"); </script> </head> <body> <div class="container"> <h1>Where to place your JavaScript code.</h1> </div> <script src="scriptS****.js"></script> </body> </html>
Steven Parker
231,269 PointsThe name of your file is "scriptS****.js
" How odd
Ashley Gandawa
3,675 PointsYour syntax in both the JavaScript and the HTML looks fine. Try checking for typographical errors. Does the name of the script file actually match the name you put in the src attribute exactly? Make sure spelling and case match exactly then try again. Usually small errors like that break our code and take hours to fix because we often have trouble finding our own typos.
2 Answers
Ashley Gandawa
3,675 PointsYour syntax in both the JavaScript and the HTML looks fine. Try checking for typographical errors. Does the name of the script file actually match the name you put in the src attribute exactly? Make sure spelling and case match exactly then try again. Usually small errors like that break our code and take hours to fix because we often have trouble finding our own typos.
Piyush Patel
17,253 PointsYes, there might be simple errors like typing the file name wrong or linking the files incorrectly in the directory path.
John Erickson
Full Stack JavaScript Techdegree Student 3,916 PointsJohn Erickson
Full Stack JavaScript Techdegree Student 3,916 PointsGood afternoon Chandni,
What you've provided is your HTML, however what your asking is regarding your javaScript file. Any chance can you repost w/ your javaScript?
Although I'm new to javaScript, your syntax looks good. I also tried it myself using the developer tools and it works.
I also found this which may help: http://www.w3schools.com/jsref/met_win_alert.asp