Help find ERROR in JavaScript

  • CGFX
  • Graduate
  • Graduate
  • User avatar
  • Posts: 161
  • Loc: Chicago, IL.

Post 3+ Months Ago

All,

I am trying to learn how to hand code JavaScript, I am learning from a Shelly Cashman Series text book from 1999 titled "JavaScript Introductory Concepts and Techniques. It is teaching I believe version 1. Can an expert quickly view the code below and tell me what is wrong? my document.write string won't render.

Thank you in advance.

Code: [ Select ]
<html>

<head>
<title>Test Your Knowledge Introduction</title>
</head>

<body>

<p align="center"><img src="CarbonCopy.jpg" width="294" height="121"></p>

<p align="center"><img src="wavygraybar.jpg" width="756" height="16"></p>

<p align="center">Welcome to Carbon Copy Printers.

<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- Hide the script from old browsers --
today = new Date()
If ((today.getHours() >=4) && (today.getHours() <=12)){
 document.write("Good Morning. Have a rush job for the afternoon? We can handle it!")
}
If ((today.getHours() >12) && (today.getHours() <=18)){
 document.write("Good Afternoon. We can have that print job ready by tomorrow morning.")
}
If ((today.getHours() >18) && (today.getHours() <=23)){
 document.write("Good Evening> We will be here all night if you need us!")
}
If ((today.getHours() >=0) && (today.getHours() <4)){
 document.write("Yes, we are working at this hour!")
}
// -- End Hiding Here -- >
</SCRIPT>

We are open 24 hours a day. No job is too big or too small.</p>

<blockquote>
 <ul>
  <li>Resumes</li>
  <li>Brochures</li>
  <li>Invitations</li>
  <li>Newsletters</li>
  <li>Posters</li>
  <li>Ads</li>
 </ul>
</blockquote>
</body>
</html>
  1. <html>
  2. <head>
  3. <title>Test Your Knowledge Introduction</title>
  4. </head>
  5. <body>
  6. <p align="center"><img src="CarbonCopy.jpg" width="294" height="121"></p>
  7. <p align="center"><img src="wavygraybar.jpg" width="756" height="16"></p>
  8. <p align="center">Welcome to Carbon Copy Printers.
  9. <SCRIPT LANGUAGE="JAVASCRIPT">
  10. <!-- Hide the script from old browsers --
  11. today = new Date()
  12. If ((today.getHours() >=4) && (today.getHours() <=12)){
  13.  document.write("Good Morning. Have a rush job for the afternoon? We can handle it!")
  14. }
  15. If ((today.getHours() >12) && (today.getHours() <=18)){
  16.  document.write("Good Afternoon. We can have that print job ready by tomorrow morning.")
  17. }
  18. If ((today.getHours() >18) && (today.getHours() <=23)){
  19.  document.write("Good Evening> We will be here all night if you need us!")
  20. }
  21. If ((today.getHours() >=0) && (today.getHours() <4)){
  22.  document.write("Yes, we are working at this hour!")
  23. }
  24. // -- End Hiding Here -- >
  25. </SCRIPT>
  26. We are open 24 hours a day. No job is too big or too small.</p>
  27. <blockquote>
  28.  <ul>
  29.   <li>Resumes</li>
  30.   <li>Brochures</li>
  31.   <li>Invitations</li>
  32.   <li>Newsletters</li>
  33.   <li>Posters</li>
  34.   <li>Ads</li>
  35.  </ul>
  36. </blockquote>
  37. </body>
  38. </html>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • CGFX
  • Graduate
  • Graduate
  • User avatar
  • Posts: 161
  • Loc: Chicago, IL.

Post 3+ Months Ago

Error Update: I receive the following error meassge for the IE devopler tool which reads: "Object expected - line 18 character 2 - Breaking on JS runtime error Object Expected".

I still don't understand??


Thanks,

cgfX
  • BooGiE_MaN
  • Proficient
  • Proficient
  • User avatar
  • Posts: 387
  • Loc: Cape Town, South Africa

Post 3+ Months Ago

Try replacing "If" with "if" - case sensitive.

By the way using Firefox and the add on "Firebug" is much more useful when looking for errors - IE will give you the most vague errors you can imagine.
  • CGFX
  • Graduate
  • Graduate
  • User avatar
  • Posts: 161
  • Loc: Chicago, IL.

Post 3+ Months Ago

BooGiE_MaN,

Thank you, I will give it a try.

cgfX

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 132 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.