Window alert() Method - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window alert

Description

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

Parameter Values

Parameter Type Description
message String Optional. text to display in the alert box, or an object

Return Value:

No return value

The following code shows how to Display an alert box:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*  ww  w.  j a va2s .  c o m*/
    console.log(location.hostname);
}
</script>

</body>
</html>

Related Tutorials