JavaScript Error message Property - Javascript DOM

Javascript examples for DOM:Error

Description

The message property sets or gets an error message.

Return Value

A String, representing a description of an error

The following code shows how to return an error message

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
try {//from   w  w w  .ja  v  a  2  s.c om
    functionDoesNotExist("hi!");
}
catch(err) {
    document.getElementById("demo").innerHTML = err.message;
}
</script>

</body>
</html>

Related Tutorials