Previous Chapter's Examples-|-Next Chapter's Examples-|-Return to Chapter Listing

Example 8.1:
You Don't (Always) Need Spaces


The script here is from Example 6.9. It works just the same, but notice that we've removed most of the spaces from the script in the HEAD:


This is the script we used. First, this in the HEAD: <SCRIPT LANGUAGE="JavaScript"> <!-- function function1(){var dToday=new Date()var nHours=dToday.getHours()var nDay=dToday.getDay()if((nDay==5)&&(nHours>=12)){alert("Thank God it's Friday afternoon")}else{if((nDay==6)||(nDay==0)){alert("Hey, it's the weekend")}else{alert("Just another day")}}} //--> </SCRIPT> With this button: <form> <input type="button" value="What day is it?" onclick="function1()"> </form>
Previous Chapter's Examples-|-Next Chapter's Examples-|-Return to Chapter Listing