Ret = prompt('Type the word castle',"");
if(Ret=="castle") {
location = 'ch03_1.html';
The prompt
The first line of the function, password() is:
Ret = prompt('Type the word castle',"");
This command tells the computer to open a prompt box, and assign whatever the user types to the variable, Ret.
Therefore if the user types "chickensoup", the computer will execute the command
Ret="chickensoup"
I can then compare the variable Ret with other text to determine if the user typed in the correct password.
The parentheses contain the message inside the prompt box, then the default text. Look at this sample command, then click the show me button
prompt("Please type your name","Newt")
|
If you do not want a default, simply place 2 quotes after the comma like I did in the original example.