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:
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?
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.
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.
On some browsers, alerts() can cause the page's tab to suddenly grab focus. Occasionally useful, mostly irritating.
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.
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
精彩评论