ÍøÂçѧԺ

w3pop.com :: ÍøÂçѧԺ :: JavaScript :: JS Popup Boxes

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

JavaScript
JSÊýѧ¶ÔÏó²Î¿¼
JS×Ö·û´®¶ÔÏó²Î¿¼
JSº¯Êý²Î¿¼
JSʼþ²Î¿¼
Javascript ³£ÓÃÕ..
FFºÍIEϵÄjs¼æÈÝ..
jQuery ¼òµ¥½éÉÜ
jQuery / ºËÐÄ / ..
jQuery / ºËÐÄ / ..
ÈçºÎʹÓÃJSÀ´ÅжÏ..
JavascriptÔÚIEºÍ..
3¸öjs×Ö·û±àÂ뺯Ê..
javascript ÖÐµÄ ..

JS Popup Boxes


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ÐÞ¸Ä:2008-05-18 ä¯ÀÀ:17383 :: ::

In JavaScript we can create three kinds of popup boxes: Alert box, Confirm box, and Prompt box.
ÔÚJSÀïÎÒÃÇ¿ÉÒÔ½¨Á¢ÈýÖÖ²»Í¬Ñù×ÓµÄpopup boxesµ¯³ö¿ò£º¾¯Ê¾¿ò£¬È·ÈÏ¿ò£¬ÐÅÏ¢¿ò


Examples
Àý×Ó

Alert box[¾¯Ê¾¿ò]

Alert box with line breaks[»»Ðеľ¯¸æ¿ò]

Confirm box[È·ÈÏ¿ò]

Prompt box[ÐÅÏ¢¿ò£¨¿ÉÊäÈë²ÎÊý£©]


Alert Box
¾¯Ê¾¿ò

An alert box is often used if you want to make sure information comes through to the user.
Èç¹ûÄãÏë±£Ö¤ÈÃÓû§µÃµ½ÐÅÏ¢¾ÍʹÓþ¯Ê¾¿ò

When an alert box pops up, the user will have to click "OK" to proceed.
µ±¾¯Ê¾¿òµ¯³ö£¬Óû§±ØÐë°´“OK”À´¼ÌÐø

Syntax:
Óï·¨£º

alert("sometext")

 


Confirm Box
È·ÈÏ¿ò

A confirm box is often used if you want the user to verify or accept something.
È·ÈÏ¿òÓÃÀ´ÈÃÓû§ºËʵ»òÊǽÓÊÜһЩÐÅÏ¢¡£

When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.
µ±ÐÅÏ¢¿òµ¯³ö£¬Óû§±ØÐë°´“OK”»òÕß“Cancel”À´¼ÌÐø

If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
Èç¹ûÓû§°´"OK"¾Í·µ»ØÕ棬°´"È¡Ïû"¾Í·µ»Ø¼Ù

Syntax:
Óï·¨£º

confirm("sometext")

 


Prompt Box
ÐÅÏ¢¿ò

A prompt box is often used if you want the user to input a value before entering a page.
ÐÅÏ¢¿òÓÃÀ´ÈÃÓû§ÔÚ½øÈëÒ³ÃæÇ°ÊäÈëÖµ¡£

When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.
µ±ÐÅÏ¢¿òµ¯³ö£¬Óû§½«ÔÚÊäÈëÖµºó°´“OK”»ò“Canel”À´¼ÌÐø£¨ÏÂÃæµÄ²Ù×÷£©

If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.
°´“OK”¾Í»á·µ»ØÊäÈëµÄÖµ£¬°´“È¡Ïû”¾Í»á·µ»Ø¿ÕÖµ

Syntax:
Óï·¨£º

prompt("sometext","defaultvalue")

ÆÀÂÛ (9) 1 2 All