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
Samual Blodgett
1,773 PointsJavaScript Dialog Box Not Showing
I just started in the JavaScript courses and quickly realize that I cannot actually view any prompt box in Chrome or Firefox on PC. I've also tried IE and Chrome on Mac. I've tried writing the code myself as well as just executing the accurate code in the workspace. In all attempts I cannot see the dialog box which is suppose to prompt the user for input. Am I somehow blocking dialog boxes?
4 Answers
sizwengubane
15,244 Pointsjust set your code like this <blockquotes>
var answer = prompt('Does this work for you?');
</blockquotes> Did this work for you?
Samual Blodgett
1,773 PointsThank you Lakindu but this also does NOT work. There are no dialog box prompting the user.
sizwengubane
15,244 Pointswtf? are u sure u included your javaScript file to your HTML correctly? it should work because now modern browsers dont block off prompt dialogs Please include the jQuery CDN also to your html maybe following these steps would help
Samual Blodgett
1,773 PointsMy HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css">
<title>Using the prompt() method.</title>
</head>
<body>
<div class="container">
<h1>Using the prompt() method</h1>
<script src="scripts.js"></script>
</div>
</body>
</html>
My .js
var visitor = promt('What is your name?');
var message = 'Hello' + visitor;
document.write(message);
sizwengubane
15,244 Pointsu made a mistake...its not promt(), its prompt(). If this is also not the case please try var visitor = window.prompt('What is your name?'); thanks
Samual Blodgett
1,773 PointsLakindu thank you! I appreciate you helping me! It was the spelling error indeed.
sizwengubane
15,244 Pointssure thing brother..please select my answer as the best answer so i can get points ^_^. I'll look forward to helping u again