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 trial

General Discussion

Browsers Won't Open

I am following along with the lessons in "Intro To Programming" and with this code:

<!DOCTYPE html>
    <html lang="en">
        <head>
            <title>Introduction To Programming</title>
            <style>
                html {
                    background:#fafafa;
                    font-family:sans-serif;
                }
            </style>
            <script src="myscript.js"></script>
        </head>
        <body>
            <h1>Introduction To Programming</h1>
            <h2>With Javascript</h2>
        </body>
    </html>


//Do a couple of console.logs
console.log("Hello from my script.js");
console.log("Hello again!"); //This is not needed
/*
var name = prompt("What is your name?");
alert("Hello " + name);

name = "Nick";
console.log("The user's name is " + name);
*/

/*
console.log("Before");

var name = prompt("What is your name");

if ("") {
    console.log("If block");
}else {
    console.log("Else block");
}

console.log("After");
*/

console.log("Before");


while(true) {
    console.log('Hello World!');
}

console.log("After");

I get a "Warning: Unresponsive Script " in Firefox and Google Chrome won't even open.

Both files are in the same folder,,,any help?

2 Answers

You're running an infinite loop:

while ( true ) {
    console.log( 'Hello World!' );
}

That loop will run as long as true evaluates to true, which is infinity. It will cause your browser to become unresponsive. Apparently, browsers have gotten smart enough to avoid things like that.

Try taking out that section of code and opening it again.

In case you're wondering why your browser did that, it's only to protect you. It can't tell the difference between a script you wrote and a script someone else wrote and you downloaded and tried to open by mistake. It only knows that you're trying to open something that could do some damage. So it doesn't allow you to open it.

Thanks, that's a great answer....quick too!!