English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
confirm()The method displays a modal dialog with an optional message and two buttons, "OK" and "Cancel".
If the user clicks "OK", the confirm() method returns true, otherwise it returns false.
Confirmation dialogs are usually used when you want the user to verify or accept something.
Dialogs are modal windows - they prevent users from accessing the rest of the program interface until the dialog is closed. Therefore, you should not overuse any functions that create dialogs (or modal windows).
window.confirm(msg)
var r = confirm("Click the button!"); if (r == true) { txt = ";Clicked Confirm!"; } else {}} txt = "clicked cancel!"; {}اختبار لمعرفة‹/›
يتم دعم طريقة Confirm() من قبل جميع المتصفحات بشكل كامل:
الطريقة | |||||
confirm() | نعم | نعم | نعم | نعم | نعم |
الم 参数 | الوصف |
---|---|
msg | (اختياري) النص الذي سيتم عرضه في نافذة التأكيد |
القيمة المعدة: | قيمة بولية تعبر عن ما إذا تم اختيار "موافق" أو "إلغاء"
|
---|
نموذج تأكيد يحتوي على مسافات
confirm("Press a button\nEither OK or Cancel.");اختبار لمعرفة‹/›
هذا المثال يوضح أنواع الحوارات المختلفة التي يدعمها جافا سكريبت:
انقر على الزر أدناه لإظهار نماذج مختلفة من الحوارات:
مرجع النافذة (Window):طريقة alert()
مرجع النافذة (Window):طريقة hint()