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 JavaScript Basics (Retired) Introducing JavaScript Your First JavaScript Program

Alert does not generate dialog box only a blank screen on chrome.

In scripts.js in the workspace when I type alert("Hello from Treehouse");

and hit preview I just get a blank screen in chrome.

7 Answers

Thomas Workman
Thomas Workman
7,173 Points

Hmm...should work. Maybe post your code just in case something is missing. Might try refreshing Chrome and trying the preview again. You can also test the same thing by opening the browser inspector in Chrome and entering alert("what ever string you want here"); in the console.

Also, jsfiddle.net is useful for doing some JS testing. Hope that helps.

The code is just

alert("Hello from TreeHouse");

I used jsfiddle.net and it seems to be working for now. Thanks.

Same issue, I have tried the above to no avail.

Same issue for me here on google Chrome. It showed the alert the very first time I typed

alert("Hello from Treehouse!");

and then saved,

but once I added the following code,

document.write(<h1>Welcome to JavaScript Basics</h1>);

alert("Thanks for visiting!");

it's not worked since, even when I commented out the last two lines like this.

alert("Hello from Treehouse!");

//document.write(<h1>Welcome to JavaScript Basics</h1>);
//               
//alert("Thanks for visiting!");

I've searched Google for answers and have tried the following solutions as well,

  1. Close offending tab and re-open
  2. Close and Restart browser
  3. Close browser and restart computer

Anyone had any luck solving this? Regards,

Mark

Same with Safari, I have tried using script.js and html file both the same, just the grey bar and nothing else when trying to view.

Nelly Nelly
Nelly Nelly
7,134 Points

Same issue here, My solution was to work in my text editor rather than the workspace and launch index.html in the browser :) It works like a charm. make sure to create the index.html, scripts.js and the folder with main.css :)