JavaScript Examples Bible Support Center

Updated Listings

  • Listing 16-13. This listing somehow escaped the CD-ROM. It provides a live example of the window.pageXOffset and window.pageYOffset properties for Netscape Navigator 4 and 6. You can open the example here, and save it to your local hard disk.
  • Listing 22-7. The printed listing needs an ID attribute for the second <MAP> tag so that it works with the makeAreas() function. The tag should read:

        <MAP NAME="lampMap" ID="lamp_map">

  • Listings 49-01 through 49-03. I forgot to take into account the smarter way that browsers and internal PC clocks treat dates with respect to the local Daylight Saving Time settings (for many parts of the world). As a result, all three calendar examples show October to have 32 days. That's because the function that calculates the number of days in a month uses the number of days between the first of the current month and the first of the next month. The math -- dividing the two dates in milliseconds by the number of milliseconds in a day -- causes this error because of the "extra hour" that occurs during the last Sunday of October (in many parts of the Northern hemisphere).

    One fix prevents calculations from using the absolute borderline case for calculating the number of days in a month. Change the getMonthLen() function as follows:

    // number of days in the month
    function getMonthLen(theYear, theMonth) {
        var oneHour = 1000 * 60 * 60
        var oneDay = oneHour * 24
        var thisMonth = new Date(theYear, theMonth, 1)
        var nextMonth = new Date(theYear, theMonth + 1, 1)
        var len = Math.ceil((nextMonth.getTime() -
            thisMonth.getTime() - oneHour)/oneDay)
        return len

    October now has 31 days, and the rest of the months continue to have the correct number of days.

    Here are the live "Month at a Glance" example files:
        Listing 49-01 (all browsers)
        Listing 49-02 (all browsers)
        Listing 49-03 (IE4+/Windows only and NN6; Do not open with IE5/Mac or Opera 5 because they do not support DOM table methods)


  • Accessing CD-ROM Files in Solaris 2.5.1. Reader Michael Bloom was kind enough to share a solution he tracked down for a problem he was having with the CD. If you are running Solaris 2.5.1 and cannot read all the files on the CD-ROM, you can obtain an official Sun patch that fixes the problem. The patch number is 104560-05 for Sparc and 104561 for Solaris/Intel.