The window. Prompt () method is often used to accept some parameters, such as common URLs and emails.
So, how does prompt pass the value? The following is an example.
1. Sample Code
Pro.htm
<Script language = JavaScript> <! -- Function Pro (){ VaR Tempa = Window. Prompt ('enter your name ',''); If (Tempa = "" | Tempa = NULL ){ Tempa = "You have not entered any text "; } Alert (Tempa ); } --> </SCRIPT> <Body onload = "Pro ()"> </body> |
2. Demo
(1) Open pro.htmin IE and you can see the following interface. When pro.htm is loaded, the prompt dialog box is automatically displayed.
You are prompted to enter parameters.
(2) After the input is complete, the received value will be returned to the variable Tempa. The next step is to determine whether the user has entered the parameter. A prompt box will pop up.
If you have a number of parameters, the information you just entered is displayed. For example, when you enter "forget your worries", the following page is displayed:
If no data is input, the following page is displayed:
String 2
String 8
After demonstration in this example, you should have some knowledge about the use of window. Prompt!