13

If there is a need to display some simple confirmation popup, most developers would rather install jQuery, find some dialog plugin for it, skin it, than put a one liner:

if(confirm("Are you sure?")) { ... }

Using alert() for displaying error messages is considered cheap.

And how many sites can you name that are usingprompt()?

So, the question is:

  1. Is there something wrong with those dialogs so they should be avoided? Yes they have (very) limited functionality and customization, but when you don't need anything fancy, is using js dialogs still a bad practice?

  2. Why these dialogs haven't seen any improvement in past 10 years (probably longer) and none is planned for near future? Wouldn't it be nice to have native js access to fully customizable desktop-level dialogs? At least adding error/warning/info type of dialogs and adding ability to customize button captions would be a big help.

1

4 Answers 4

14

alert displays a modal dialog box which effectively disables the browser UI until it is dismissed. Most developers consider that to be bad design and most users consider that irritating.

One of the main issues that I find with modal dialogs is that they don't let me open a new tab and do a quick Google search before responding to them.

4
  • 2
    So why nobody ever considered adding non-modal option to them?
    – serg
    Apr 5, 2010 at 6:16
  • There are plenty of HTML-based alternatives you can use. Apr 5, 2010 at 6:22
  • The last thing you mentioned always irritated me too, but it does not seem to be an issue in any modern browsers today.
    – tjespe
    Nov 23, 2017 at 20:17
  • @tjespe those were the days
    – Amarghosh
    Nov 23, 2017 at 21:58
2

On some browsers, alerts() can cause the page's tab to suddenly grab focus. Occasionally useful, mostly irritating.

1

One of the resons why i do not use prompt or confirm or alert too much, is that they freeze all other browser UI. They dont allow the user to switch to another tab or do anything else w/o dismissing the dialog.

0

Cuz they are ugly and disrupt the user experience by popping up a gray box out of nowhere. Its better to have a HTML dialog conforming to your website themes and look n feel

O yeah. and they are modal. This adds insult to injury

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.