Window.confirm usage
The Confirm () method displays a dialog box with the specified message and OK and Cancel buttons.
Example
| The code is as follows |
Copy Code |
|
<a href= "" Javascript:if ("Confirm that you want to delete this content?") location= "del.asp?&areyou= Delete &id=1" "> Delete </a> |
To define a function, the advantage is that it can be called repeatedly:
| The code is as follows |
Copy Code |
|
<script language= "JavaScript" >
function Del_sure () {
var gnl=confirm ("OK to delete?");
if (gnl==true) {
return true;
}else{
return false;
}
}
</script>
|
With all this talk, we're going to get down.
| The code is as follows |
Copy Code |
|
<title>validator</title>
<script type= text/ JavaScript
function Checkform () {
if window.confirm ("Are you sure you want t o sumbit this form? ") {
return true;
}
return false;
}
</SCRIPT>
<body>
<form action= "2.html" onsubmit= "Return checkform [)"
please click the submit button:<br>
<input Type= "Text" name= "text" value= "text" ><br>
<input type= "Submit"
</form
</body>
|
The
Core is this sentence if (window.confirm ("Are you sure your want to sumbit this form?"), it returns True when we click Yes and then commits, otherwise it cancels the operation.