JavaScript pop
JavaScript can create three kinds of message boxes: warning box, check box, balloon.
Alert box
Alert box is often used to ensure that users can get some information.
When the warning box appears, users need to click on the OK button to continue.
grammar
window.alert () method can not take the window object, the direct use alert () method.
Examples
<Html>
<Head>
<Script>
function myFunction ()
{
alert ( "Hello, I'm a warning box!");
}
</ Script>
</ Head>
<Body>
<Input type = "button" onclick = "myFunction ()" value = "display a warning box">
</ Body>
</ Html>
try it"
Confirmation box
Check box is typically used to verify whether to accept a user operation.
When a confirmation pop-up card, the user can click "OK" or "Cancel" to determine the user operation.
When you click "OK" to confirm box returns true, if you click "Cancel" check box returns false.
grammar
window.confirm () method can not bring the window object directly confirm () method.
Examples
if (r==true)
{
x="你按下了\"确定\"按钮!";
}
else
{
x="你按下了\"取消\"按钮!";
}
try it"
Balloon
Prompt box is often used to prompt the user to enter a value before entering the page.
When the prompt box appears, users need to enter a value, then click OK or Cancel button to continue operation.
If the user clicks to confirm, the return value is entered. If the user clicks Cancel, the returned value is null.
grammar
window.prompt () method can not bring the window object directly prompt () method.
Examples
if (person! = null && person! = "")
{
x = "Hello" + person + "! How are you feeling today?";
. Document.getElementById ( "demo") innerHTML = x;
}
try it"
Wrap
Pop with a backslash + "n" (\ n) to set the wrap.