Usage: Confirm (< string >); pop up a dialog box with OK and Cancel buttons, display < string > content, ask the user to make a choice, the entire document read, Script run will be paused. Returns a true value if the user presses OK, and returns a value of False if "cancel" is pressed.
if (Confirm ("confirm submission"))
{
}
Instance
<a href= "Web effects: if (Confirm (' Confirm deletion? ')) window.location= ' del.asp Tutorial ' > Delete </a>
Of course, you can write confirm in a function.
<script language= "JavaScript" >
function Confirmdel (str) {
return confirm (str);
}
</script>
<a href= "delete.asp" onclick= "return Confirmdel (' OK to delete ')" > Delete </a>
Confirm Line Change
<script>
function Checkadspos (Pos) {
if (Pos!=0) {
var msg = document.getElementById ("confirmmsg" +pos). Value;
msg = Msg.replace ("n", String.fromCharCode (10));
Confirm (msg);
var msg = document.getElementById ("CONFIRMMSG1"). Value;
Alert ("N". charCodeAt ());
Alert (String.fromCharCode (10));
Alert (document.getElementById ("CONFIRMMSG1"). Value.charcodeat ())
}
}
</script>
<input id= "CONFIRMMSG1" type= "hidden" value= "n" >
<input id= "CONFIRMMSG2" type= hidden "value=" You??? The 2nd line. N. Line ">
<input id= "CONFIRMMSG3" type= hidden "value=" You??? The 3rd line. N. Line ">
<input id= "ConfirmMsg4" type= hidden "value=" You??? The 4th line. N. Line ">
<input id= "ConfirmMsg5" type= hidden "value=" You??? The 5th line. N. Line ">
<input id= "ConfirmMsg6" type= hidden "value=" You??? the 6th line. N. Line ">
<input id= "ConfirmMsg7" type= hidden "value=" You??? The 7th line. N. Line ">
<input id= "ConfirmMsg8" type= hidden "value=" You??? The 8th line. N. Line ">
<select name= "Adspos" size= "1" "id=" Adspos "onchange=" return Checkadspos (This.options[this.selectedindex].value); " >
<option value= "0" SELECT> </option>
<option value= "1" > Line 1th </option>
<option value= "2" > Line 2nd </option>
<option value= "3" > Line 3rd </option>
<option value= "4" > Line 4th </option>
<option value= "5" > Line 5th </option>
<option value= "6" > Line 6th </option>
<option value= "7" > Line 7th </option>
<option value= "8" > Line 8th </option>
</select>