Confirm Function
The confirm function is used to provide the confirmation function. It first displays the information contained in the given message parameter, and provides two optional answers: "OK" and "cancel ", then wait for the user to select one of them. If the user selects "OK", true is returned; otherwise, false is returned if "cancel" is selected. The syntax format of this function is as follows:
Window. Confirm (message, OK, cancel)
It has three parameters. The message parameter is a prompt message in the string format to be displayed, and the OK parameter is also a string information to be displayed. It can be "OK ", it can also be other text information that indicates OK, such as "I agree" and "I like". Similarly, the cancel parameter is used to display string information, it can be a "cancel" text or other text information that represents the meaning of cancel.
<SCRIPT>
VaR bln = Window. Confirm ("OK? ");
Alert (BLN)
</SCRIPT>
Or
Button. Attributes. Add ("onclick", "javascript: If (! Confirm ('Are you sure you want to delete this system for consultation? ') {Return false ;}")
Button. Attributes. Add ("onclick", "javascript: Return confirm ('Run after login. Do you want to log on again now? ')")
Example: <a onclick = "javascript: If (! Confirm ('Are you sure you want to delete the selected information? /N this operation cannot be restored! ') {Return false;} "href =" delhtml. asp? ADid = <% = RS ("ADid") %> & type_oneid = <% = RS ("type_oneid ") %> "> <font color =" green "> Delete </font> </a>
Example:
Put the following in
<SCRIPT>
Function rusure ()
{
Question = confirm ("are you sure you want to enter? ")
If (question! = "0 ")
{
Window. Open ("", "test announcement window", "width = 340, Height = 163, toolbar = 0, status = 0, menubar = 0, resize = 0 ");
}
}
</SCRIPT>
Put the following in <body> </body>
<A href = "" onclick = "rusure (); Return false;"> click me </a>
Use confirm to confirm the submission action and submit the confirmation prompt
For example, when you click rewrite in the message book, sometimes we want a prompt to avoid mistakes. The Code is as follows:
Method 1
<Input name = "Submit" type = "Submit" onclick = "If (confirm ('Open webpage? ') Location = 'HTTP: // www.05376.com' "value =" open ">
Method 2
<Input name = "reset" type = "reset" onclick = "Return clearbutton ()" value = "Override">
<SCRIPT type = "text/JavaScript">
Function clearbutton ()
{
If (! Confirm ("are you sure you want to rewrite it? ") Return false;
}