JavaScript JavaScript Basics (Retired) Introducing JavaScript Your First JavaScript Program

Issues with Chrome?

I've tried using a simple server ( to follow along on my localhost but the code from this video doesn't work in Chrome for me. It works in firefox though. In Chrome only the first alert shows and neither the document.write function nor the second alert run, but they work in FireFox.

Can someone help me understand whats going on?

2 Answers

Brendan Whiting
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,667 Points

I found a stack overflow article that explains this idiosyncrasy:

You would need to wrap it like this:'text/html');
document.write("<h1>Welcome to JavaScript basics</h1>")

In real life we hardly ever use document.write, so don’t worry about it too much.

Katherine Webster
Katherine Webster
Pro Student 1,435 Points

Thank you! I could not figure out why it wasn't working.

Christian Emenike
Christian Emenike
3,787 Points

This was a shock but thanks Brendan Whiting for the rescue.