What is JavaScript dialogs in hindi-जावास्क्रिप्ट दिअलोग्स क्या है?

हेल्लो दोस्तों ! आज इस पोस्ट में जावा स्क्रिप्ट के बारे में बताया गया है की JavaScript dialogs in hindi क्या होता है कैसे काम करता है और भी बहुत कुछ दिया गया है तो चलिए शुरू करते है

JavaScript dialog’s का परिचय

dialog box एक छोटी दूसरी window होती है जो की current window के अन्दर ही generate होती है जो की इन्हे popup boxes भी कहते है dialog boxes के द्वारा 3 तरह के काम किये जा सकते है

  • आप कोई भी alert show कर सकते है
  • user से कोई भी task को perform करने से पहले confirm कर सकते है
  • input की requirement होने पर user से input ले सकते है

JavaScript में dialog boxes उनके काम के according 3 तरह के होते है इनके बारे में आपको निचे दिया जा रहा है

alert dialog box

alert box के user को कोई important message में show करने के लिए प्रयोग किया जाता है जब आप चाहते है की user आपके message को जरुर पढ़े ऐसी situation में आप alert box का प्रयोग कर सकते है ये box current window से focus हटा देता है

और only message show होता है साथ ही alert box में एक OK का button भी होता है जिस पर click करने से alert box हट जाता है

JavaScript में alert dialog को generate करने के लिए आप alert function को कॉल करते है इस function में आप जो message show करना चाहते है उसे argument की तरह लिखते है जिसका आपको example निचे दिया जा रही है

<html>
<head>
<title>alert box demo</title>
</head>
<body>
<script type=”text”/javascript”>
Alert(“this is an alert box”);
</script>
</body>
</html>

उपर दिए जा रहा इस प्रोग्राम का output आपको निचे generate होता है

confirm dialog box

confirm dialog box user से किसी task के बारे में confirmation लेके के लिए प्रयोग किया जाता है ये एक छोटी सी window होती है जिस्म yes और no buttons होती है जिसमे yes button का user की सहमती को दर्शाती है और no button को show करता है की user proceed करना नहीं चाहते है

JavaScript में confirm dialog box को generate करने के लिए आप confirm method को call करते है इस method में आप एक message argument की तरह pass करते है जो की user से confirmation मांगता है जैसे की आप user से पूछते है की आप ये block खरीदना चाहते है तो आपको इसका प्रोग्राम निचे दिया जा रहा है

<html>
<head>
<title>confirm dialog demo</title>
</head>
<body>
<script type=”text”/javascript”>
If(confirm(“Do yout want to buy this book?”))
{
    Document.write(“user wants to buy the book”);
}
</script>
</body>
</html>

उपर दिए गए example में यदि user confirm box में yes को select करता है तो इफ statement में दिया गया message webpage पर print हो जाता है ये script आपको निचे दिया web page को generate करती है

diagram

यदि user ok पर click करता है तो message show होता है नहीं तो कुछ भी show नहीं होता है

prompt dialog box

यदि आप user से कोई input लेना चाहते है तो आप prompt dialog box का user का सकते है prompt dialog box में एक text box होता है और एक ok button होता है text-box में user वैल्यू को input करता है जो की prompt box को create करने के लिए आप prompt() method को कॉल करते है इस method में 2 parameters को pass किये जाते है

पहल parameters वो label होता है जो की text-box में क्या वैल्यू डालती है ये show करता है दुसरे पैरामीटर में text-box की default value को pass की जाती है जिसका आपको example निचे दिया जा रहा है

<html>
<head>
<title>prompt box demo</title>
</head>
<body>
<script type=”text”/javascript”>
Var age=prompt(“enter your age”,20);
Document.write(“age is :”,age);
</script>
</body>
</html>

उपर दिए गए script में निचे दिया गया web page को generate करता है

user जो की value को input के रूप में देगा ok पर click करने पर उसे appropriate message के साथ print किया जायेगा

JavaScript dialogs in hindi

reference-https://www.tutorialspoint.com/javascript/javascript_dialog_boxes.htm

निवेदन:-आप सभी छात्र –छात्रों से निवेदन है की अगर आपको ये Topic( JavaScript dialogs in hindi) अच्छा लगा हो तो कृपया आप इस वेबसाइट के बारे में अपने दोस्तों को जरुर बताये अगर कोई topic( JavaScript dialogs in hindi)से संबधित प्रश्न हो तो कमेंट्स(comments) आपके लिए ही बना है और किसी Subject के लेकर भी कोई प्रश्न हो तो कमेंट करे

Leave a Comment