The Confirm () method is used to display a dialog box with the specified message and confirmation and Cancel buttons.
If the visitor clicks OK, this method returns True, otherwise false is returned.
Grammar
Confirm (str);
Parameter description:
STR: The text return value to display in the message dialog box: Boolean value
Note: By returning a value you can tell what button the user clicked.
Note: If true is changed to false, the result is the opposite
Instance
1 <script type= "Text/javascript" >2 var mymessage=confirm ("Do you like JavaScript?") ); 3 if (mymessage==true) 4 { document.write ("Very good, come on!") ); } 5 Else 6 { document.write ("JS powerful, to learn Oh!") ); } 7 </script>
Full instance
1<! DOCTYPE html>234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title>confirm</title>6<script type= "Text/javascript" >7 functionRec () {8 varMymessage=confirm ("Excuse me, are you a man or a lady?")) ;9 if(mymessage==true)Ten { Onedocument.write ("You're a lady!")); A } - Else - { thedocument.write ("You're a man!")); - } - } -</script> + -<body> +<input name= "button" type= "button" onclick= "Rec ()" value= "Click Me, Pop Up confirmation Dialog"/> A</body> atThe Javascript-confirm of Mu-class net