Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

William Lynch
William Lynch
5,636 Points

I can’t get my JavaScript Basics First Program to preview.

Sorry about this. I'm a newbie on javascript and html. I have tried to just paste it to the question. Maybe the html code is being run instead just being part of the text. I would be glad to email it if that would help. I'm kind of stumped.

I can’t get my JavaScript First Program to preview. I launched the workspace and clicked preview and the screen just blinked. Nothing else. I added an alert statement to the blank scripts.js file and same thing.

Here is the html file with no changes made:

<!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>

Any help would be greatly appreciated. Bill

Demian Martinez
Demian Martinez
2,985 Points

Hi Bill, Can you please post your javascript code so we can take a look at it. Make sure you linked the .js file correctly in the html or it won't run the code.

-Demian

William Lynch
William Lynch
5,636 Points

I have tried to just paste it to the question. Maybe the html code is being run instead just being part of the text. I would be glad to email it if that would help. I'm kind of stumped.

For some reason it didn't copy the html data. Sorry, I'm new at this. If you know of a way to do it, I'll give it a try.

If possible, could you go to the javascript basics course and launch the workspace directly.

I can’t get my JavaScript First Program to preview. I launched the workspace and clicked preview and the screen just blinked. Nothing else. I added an alert statement to the blank scripts.js file and same thing.

Here is the html file with no changes made:

<!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>

Any help would be greatly appreciated. Bill

Demian Martinez
Demian Martinez
2,985 Points

Just highlight your code and paste it in the comment box nothing else. Don't worry about syntax highlighting.

William Lynch
William Lynch
5,636 Points

Ok, thanks I'll see what I can do at my end. I'll contact their help desk and see if they have any ideas.

Bill

2 Answers

Demian Martinez
Demian Martinez
2,985 Points

Thanks Bill. I forked your snapshot and tested it in my browser and the alert is running fine. document.write() is not writing anything to the webpage because there isn't anything in the parenthesis. Looks like the problem is on your end.

William Lynch
William Lynch
5,636 Points

It seems to work on Chrome and Firefox. That was a suggestion from the help desk. I told them to close out the item.

Unfortunately for me, I don't like either one of those browsers. Does anyone have any idea on how to get Internet Explorer to work with this?

Anyway, thank you all for your work.

Bill

Demian Martinez
Demian Martinez
2,985 Points

That makes sense because I'm actually using Google Chrome.