Warning (alert)
Did you ever get into a situation like this when you visit a website? "Boom", a small window appears in front of you, with a piece of warning text written, or other information. If you don't click OK, you won't be able to do anything with the page. Yes, this little "boom" window is alert.
The following code is an instance of using alert.
<script type= "Text/javascript" >
alert ("I am a rookie I am afraid of who");
</script>
My personal view is to use alert as little as possible and it is unfriendly. It may even make some parties think your site is dangerous. Confirmation (confirm)
A confirmation box is used to let the user choose whether a problem is realistic.
Said Yes or No. Quick answer. ”
If you want to express such meaning, then confirm is more suitable. Look at the following code: we use confirm ("Are you a rookie?"). To ask the visitor, variable R saves the visitor's response, and it can only have two values: TRUE or FALSE. Yes, it's a Boolean value. The statement behind confirm is a different response to our visitors ' answers.
<script type= "Text/javascript" >
var r=confirm ("Are you a rookie?");
if (r==true)
{
document.write ("Same as");
}
else
{
document.write ("admire admire");
}
</script>
questions (Prompt)
Prompt is similar to confirm, but it allows visitors to enter the answer at random. Let's revise the example of the previous switch, and we'll make a different evaluation based on the score, but the procedure is not complete, it doesn't ask us for a score, it's supposed to be 65 points. It's not fair. Now I can use prompt to ask visitors questions, use score to store user input answers, and the rest is done by the switch behind.
<script type= "Text/javascript" >
function Judge () {
var score;//fractional
var degree;//fractional rank
score = Prompt ("What's Your score?") ")
if (Score >) {
degree = ' fool me. 100 cent full. ';
}
else{
switch (parseint (SCORE/10)) {case
0: Case
1: Case
2: Case
3: Case
4: Case
5:< C15/>degree = "Congratulations, hang up again." ";
break;
Case 6:
degree = "barely pass";
break;
Case 7:
degree = "do, make up" break
;
Case 8:
degree = "8 wrong, 8 wrong";
break;
Case 9: Case
Ten:
degree = "Master Master, admire admire";
} End of Switch
}//end of Else
alert (degree);
</script>