Prompts pop up on entering a website usually, but can also be brought up when a function has a prompt (well go over functions in the next lesson). Prompts are used to get information from the person looking at your website, then you can use that information however you like. In this case i used the information you gave me and put it in the top left corner to tell you hi. Sometimes prompts dont work if you have pop up blockers or you are very secure, in order to see the prompt if you are secured, add this site to your trusted list.
Let me show you some code:
var prompt_name = prompt("Hey please enter your name below:","Write your name here");
The code should be one line but it couldnt all fit, sometimes that will happen dont get too bent in shape about how to write it exact.
This bit of code as you see is a variable, and its name is prompt_name. This is not a special variable, its exactly the same as all the other variables, it is just a place to store information. The information we are storing is whatever the person writing in the prompt says. Then we have prompt("",""). Inbetween the first quotations is what you want people to enter in the box, it will be above the text box. Then the second quotations are what you put inside the text box, it isnt necessary and if you dont want anything in the text box just leave the space inbetween the 2 quotations empty.
Now whatever the person using the prompt puts in the text box will be stored in the variable "prompt_name". The retrieve this information you could just use document.write(prompt_name).
Now is the alert code:
alert("You clicked the button!");
Click the button below to see the result.
Kind of fun right?
This code says that we are going to make an alert box when you click the button.
As you can notice that isnt the complete code to make the alert/button combination. In HTML, is the button lesson, you need to learn that to understand the rest of the code. I will write the rest of the code for you.
<button onClick="alert('You clicked the button!');">Alert</button>
Lets go over the code:
Join our Website's Jester Forum today!
Its FREE and easy......
Status: SITE OPENED
Enjoy the STAY
If you enjoyed this page,
add 2 favorites or tell a friend