DEV Community

Cover image for Alerts, Prompts and Confirm in Javascript
Kenechukwu Nwobodo
Kenechukwu Nwobodo

Posted on

Alerts, Prompts and Confirm in Javascript

They are quite some Javascript functions, I discovered that quite a few beginners may really in need of or might need a better understanding of the functionality and how they interact with the browsers.

Firstly, we will be looking into Alert. Hmmmm, not like credit alerts 🙂, so you don't have to get your hopes up so high.😄

• What is alert ?
Basically alert makes use of a modal to display messages to the users (visitors of the website) in the browsers.

Let's take a look at the code below,
Javascript alert

• What is Prompt ?
Prompts enables the owner of the website to ask users/ visitors question(s) before they proceed to using the website.
Eg.

Javascript Prompt

• What is confirm ?
Confirm looks like prompts in terms of the syntax but with the exception that it does not give an optional reply.

Javascript confirm function

Disadvantages of making use of this Javascript interaction functions.

• The browser displays it's where it wants it to be displayed. Mostly it's in the top center of the webpage.
• You can't format like increase the width, add color to the modal etc.
• You must opt out by clicking ok, cancel or ESC key before you continue using the webpage.

Aaya, this are all I can come up with for now, please kindly write under the comment section of they is anything you may wish to add to it or any corrections to the article. This would so mean mean alot to someone out there.

Thank you for reading!

Top comments (4)

Collapse
 
tassoman profile image
Tassoman

The problem with browser's modal is they are not accessible and can be bypassed opting out nags.

The better choice is always using a js design framework for drawing modals

Collapse
 
kene_nwobodo profile image
Kenechukwu Nwobodo

Yeah, like popper.js framework

Collapse
 
asyraf profile image
Amirul Asyraf

Is confirm will give a modal like prompt to user ?? I'm curious to know

Collapse
 
tassoman profile image
Tassoman

Confirm does a modal with yes / no buttons