By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

JavaScript Window Alert Method

The alert method can be used to show alert boxes to users.

Edited: 2012-12-30 04:05

One of the most popular uses of the JavaScript alert method here on Brugbart, is in our code examples. The alert method can also be useful to display information to users of your website, while not requiring a response.

If you want to have more control over how the dialog box looks, you may want to consider making your own with HTML elements styled with CSS.

JavaScript Alert Example

The below example shows how to show a alert box when the user clicks a button on a webpage:

<!DOCTYPE html>

  <title>JavaScript Alert Box Test</title>
  <script type="text/javascript">
    function SayHallo() {

  <button onclick="SayHallo()">Say Hallo!</button>

Brugbart Vision!