- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
1. Alert − The Window.alert() method displays an alert dialog with the optional specified content and an OK button.
For example, if you execute the following script, it'll open an alert box with the content: "This is an alert" with a confirmation button.
<script> alert("This is a alert"); </script>
Note that the alert dialog should be used for messages which do not require any response on the part of the user, other than the acknowledgement of the message.
2. Confirm − The Window.confirm() method displays a modal dialog with an optional message and two buttons: OK and Cancel.
For example, if you execute the following script, it'll open a confirmation box with the content: "Please confirm this action" with a confirmation button and cancellation button. This returns a boolean depending on the input provided by the user.
<script> let bool = confirm("Please confirm this action"); console.log(bool); </script>
If you click confirm, it'll return true. If you click cancel, it'll return false.
Note that Dialog boxes are modal windows — they prevent the user from accessing the rest of the program's interface until the dialog box is closed.
3. Prompt − The Window.prompt() displays a dialog with an optional message prompting the user to input some text.
For example, if you execute the following script, it'll open a propmt box with the content: "Please enter your name" with a confirmation button and cancellation button. This returns a String provided by the user.
<script> let name = prompt("Please enter your name"); console.log(name); </script>
When you give it some input in the prompt, it'll log your name to the console.
- Can selenium handle Windows based pop up?
- Fetch value from Alert pop up in jQuery
- Emulator Window not pop up in my Android Studio
- What are the different types of LED available?
- How many types of JDialog boxes can be created in Java?
- How to close the pop up window in selenium running?
- What are the different types of wait available in Selenium?
- What are different types of access modifiers available in C#?
- How to automate menu box/pop up of right click in Python Selenium?
- How to bring up list of available notification sounds on Android?
- Types of Capital: Authorized, Issued, Subscribed, and Paid-Up