Javascript Reference - Window console.log() Method








The alert() method displays an alert box with a specified message and an OK button.

Browser Support

alert Yes Yes Yes Yes Yes

Syntax

alert(message)

Parameter Values

Parameter Description
message Optional. Specifies the text to display in the alert box




Return Value

No return value.

Example

The following code shows how to display an alert box.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from w  w w.j a  v  a 2 s.  co m-->
    alert("Hello! I am an alert box!");
}
</script>

</body>
</html>

The code above is rendered as follows: