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

Luis Rabines
20,308 PointsI need to do a popup window that ask the user if they are 21 or not. This needs to load first. can someone help me ?
I wanted to use javascript but i don't know where to begin.
2 Answers

Jeff Everhart
21,732 PointsYou have a couple of options depending on whether or not you want them to choose between yes/no or actually enter their age.
You could simply do something like window.prompt("Please enter your age);
or window.confirm("Click ok if you are over 21");
If you include this script in the head of your HTML it will execute before the rest of the page loads.
You can read more about JS popups here: http://www.w3schools.com/js/js_popup.asp

Edgar Gil
13,322 PointsIf you want your javascript to load first you just need to include your script inside the head for ex: <!DOCTYPE html> <html> <head> <title>Your Page</title> <script src="myscript.js"></script> </head> <body> </body> </html
Then inside your "myscript.js"
You can do two commands.
//First Ex: prompt("Are your 21 Years Old Or Not");
//Second Ex: alert(""Are your 21 Years Old Or Not");
//Third Ex: window.confirm("Click Ok if you are over 21");
Hope this helps.

Jeff Everhart
21,732 PointsYes! The only issue with alert might be if they need to accept user input.

Edgar Gil
13,322 PointsThanx for the feedback Jeff Everhart. I misread the question.