JavaScript, Pop-up Windows.
can be in JavaScript Create three message boxes: warning boxes , confirmation boxes , and prompt boxes .
Warning Box
Warning boxes are often used to ensure that users can get some Information.
When the warning box appears, the user needs to click the OK button to continue the Operation.
Grammar
window.alert (" sometext " |
Window.alert ()? method can be carried without the window object, directly using Alert () Method.
Instance
<! DOCTYPE html> <html> <head> <script> function myFunction () { alert (" hello, I am a warning Box!") "); } </Script> </head> <body> ? <inputtype="button"onclick="myFunction ()"value=" show Warning box "> ? </body> </html> |
Confirmation box
A confirmation box is typically used to verify that a user action is Accepted.
When the confirmation card POPs up, the user can click " confirm " or " cancel "
When you click " Confirm ", the Confirmation Box returns true , If you click " cancel ", The confirmation box returns false.
Grammar
window.confirm (" sometext " |
window.confirm ()? method can be carried without the window object, directly using Confirm () Method.
Instance
var r=confirm (" Press the button "); if (r==true) { x=" you pressed it. \ " OK \" button ! " ; } Else { x=" you pressed it. \ " cancel \" button ! " ; } |
Prompt box
The prompt box is often used to prompt the user to enter a value before entering the Page.
When the prompt box appears, the user needs to enter a value and then click the Confirm or Cancel button to continue the Manipulation.
If the user clicks confirm, then the return value is the value Entered. If the user clicks cancel, The return value is null.
Grammar
window.prompt (" sometext "," defaultvalue " |
window.prompt ()? method can be carried without the window object, directly using prompt () Method.
Instance
var person=prompt (" Please enter your Name. "," Harry Potter "); if (person!=null && person!="") { x=" Hello " + person + "! How are you feeling today? ?" ; document.getElementById ("demo"). innerhtml=x; } |
Line break
The pop-up window uses a backslash + "n" to set the line Break.
Instance
Alert ("hello\nhow is You?") ); |
?
?
?
Reference Documents:
Beginner's Tutorial -javascript Pop -up window
JavaScript pop-up window