1<! DOCTYPE HTML >234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title> we interact under </title>6<script type= "Text/javascript" >
//First prompt, after confirm 7function str () { 8var a=prompt ("JS advanced"); 9 if ("JS advanced article") {//return value is "JS Progressive article"var b=confirm ("Focus on JS high-level article"); One } }
-</script> - the - -<body> -<input name= "button" type= "button" onclick= "str ()" value= "Commit"/> + -</body> +Output:
The Prompt message dialog box (including a OK button, a Cancel button and a text input box) is popped up to display the JS advanced text, and the Confirm Message dialog box (which includes a OK button and a Cancel button) is displayed when the input box is entered into the JS Advanced page.
"Focus on JS Advanced chapter"
First confirm, then prompt.
1function str () {2var a=confirm ("JS advanced article"); 3 if (a==true) {//return value is True4var b=prompt ("Focus on JS Advanced article"); 5 }6 }
Output:
First pop-up Confirm message dialog box (including a OK button and a Cancel button), display "JS Advanced article", click OK, pop-up display "JS Advanced" prompt message dialog box (containing a OK button, Cancel button and a text input box), in the Text input box Input JS Advanced Chapter
Prompt return value: Click OK button, the contents of the text box will be the function return value ; Click the Cancel button to return null
Confirm return Value: Returns Truewhen the user taps the "OK" button and returns false when the user taps the "Cancel" button
JS Prompt and Confirm message dialog small knowledge points