<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript setTimeout with Alert Box</title>
</head>
<body>
<script type="text/javascript">
function tMessage() {
var time=setTimeout("alert('When you click press, Alert box will open in 2 seconds.')", 2000);
}
</script>
<form>
<input type="button" value="Open Alert Box" onClick="tMessage()"/>
</form>
</body>
</html>