Jump to content

book example of inline javascript won't work


how and why

Recommended Posts

I am in the process of teaching myself HTML, CSS, and Javascript from Sam's teach yourself book. The following example is an example of book examples I have had to recode to make them work. I have been able to figure out why all but this one would not work.

blah...blah...blah
<body>
  <h1>blah.blah</h1>

<script type="text/javascript">
now = new Date();
localtime = now.toString();
utctime = now.toGMTString();
document.write("<p><strong>Local time:</strong> " + localtime + "</p>");
document.write("<p><strong>UTC time:</strong> " + utctime +"</p>");
  ...and so on ...



















 



















I had to run the javascript from a linked file. Has this type of inline scripting been deprecated since the book was published in 2014? If not, What am I missing?

 

Thanks for your replies.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...