user1369975 user1369975 - 1 year ago 58
HTML Question

Why the Javascript does not run?

I am a newbie in web development and tried my hand the following code:

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>A Generic Page </title>
<script type="text/javascript">
setTimeOut(wakeUpUser, 5000);
function wakeUpUser() {
alert("Time to make life interesting");
<h1>Just a generic heading </h1>
<p>Just a normal paragraph</p>

But the script does not run only a boring static HTML page.I am following the HeadFirst Javascript Programming.Is the book wrong on this example?

Answer Source

This is the Script error in your code, modify the "SetTimeout" to an actual case. I have attached both the result of your code and Bug Fixed code results, where SetTimeout code fix suggested works fine.

setTimeout(wakeUpUser, 5000);

Your Code Before Fix: Code with Script Error

Result After Bug Fix:

Working Code