Search code examples
javascriptmessagebox

In JavaScript, is there more proper function for information pop-up than alert()?


I want to inform user about successful ajax request by a javascript information pop-up box.

Alert does what I want, but from semantic point of view it has more of a warning purpose.

Confirm and prompt are for different purpose too.

Is there semanticly more proper information box than alert? E.g. something like MsgBox() ?


Solution

  • Javascript providing a semantic message to the user is a misnomer. Messaging should be handled by HTML.

    Others here are recommending third party solutions for 'message boxes' but IMO that does not answer your question. There is no semantic information popup box in javascript besides alert, confirm, and prompt.

    The alert box is part of the browser environment, and is actually part of the window object, which is provided by the browser. For this reason alert,prompt,confirm aren't even native to EcmaScript

    So if you want a semantic way to inform a user, then you use semantic markup in HTML, and have the content revealed using javascript via DOM manipulation, whether its written by yourself or with plugin suggestions as others have written.