- Alert Dialog Box
- Confirm Dialog Box
- Prompt Dialog Box
Alert Dialog Box
यह box user को alert message दिखाने के लिये प्रदर्शित किया जाता हैं ये box current window से focus हटाकर alert box में focus करता है इस box में केवल massage show होता हैं और alert box में एक ok का button होता हैं जिस पर click करने से alert box हट जाता हैं|
Q :- Alert Dialog Box in JavaScript.
Source Code :
<!DOCTYPE html> <html> <head> <title>Alert Dialog Box</title> </head> <body> <script type="text/javascript"> alert("this is alert dialog box"); </script> </body> </html>
Output :-
this is alert dialog box
Confirm Dialog Box
यह box user से किसी task के बारे में confirmation लेने के लिए use किया जाता हैं यह एक छोटी सी window होती हैं जिसमें OK और Cancel button होते हैं जिसमें OK button user की सहमती दर्शाता हैं और Cancel button show करता है कि user process नहीं करना चाहता हैं|
Q :- Confirm Dialog Box in JavaScript.
Source Code :
<!DOCTYPE html> <html> <head> <title>Confirm Dialog Box</title> </head> <body> <script type="text/javascript"> if(confirm("Do you want to buy this book?")) { document.write("yes i want to buy the book"); } </script> </body> </html>
Output :-
yes i want to buy the book?
Prompt Dialog Box
यदि हम user से कोई input लेना चाहते हैं, तो हम Prompt Dialog Box का use करते हैं,Prompt Dialog Box में एक text-box और ok,Cancel button होता हैं text box में user value input करता हैं| Prompt box को create करने के लिए prompt() method को call करते हैं इस method में दो parameters pass किये जाते हैं पहला parameter में label होता हैं जिसमें user value input करता हैं, और दूसरें parameter में default value pass की जाती हैं|
Q :- Prompt Dialog Box in JavaScript.
Source Code :
<!DOCTYPE html> <html> <head> <title>Prompt Dialog Box</title> </head> <body> <script type="text/javascript"> var age; age=prompt("Enter Your Age",18); document.write("Age is : "+age); </script> </body> </html>
Output :-
Age is : 18
Post a Comment
If you have any doubts,Please let me know