adding last modified date at end of webpage

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmarcrum
    New Member
    • Oct 2007
    • 105

    adding last modified date at end of webpage

    Hi everyone,

    Thank you in advance for your help on this!!

    I have the below javascript at the bottom of my SHTML webpage. It gives and "undefined NaN" error when I test it. However, the code works fine in HTML. I have to keep the webpage in SHTML format due to includes... can someone help me modify my javascript so it will work?

    Code:
    <SCRIPT language=JavaScript type=text/javascript>
                                                    <!-- Begin
                  var days = new Array(8);
                  days[1] = "Sunday";
                  days[2] = "Monday";
                  days[3] = "Tuesday";
                  days[4] = "Wednesday";
                  days[5] = "Thursday";
                  days[6] = "Friday";
                  days[7] = "Saturday";
                  var months = new Array(13);
                  months[1] = "January";
                  months[2] = "February";
                  months[3] = "March";
                  months[4] = "April";
                  months[5] = "May";
                  months[6] = "June";
                  months[7] = "July";
                  months[8] = "August";
                  months[9] = "September";
                  months[10] = "October";
                  months[11] = "November";
                  months[12] = "December";
                  var dateObj = new Date(document.lastModified)
                  var wday = days[dateObj.getDay() + 1]
                  var lmonth = months[dateObj.getMonth() + 1]
                  var date = dateObj.getDate()
                  var fyear = dateObj.getYear()
                  if (fyear < 2000) 
                  fyear = fyear + 1900
                  document.write("Last modified on " + lmonth + " " + date + ", " + fyear)
                  // End -->
                                                </SCRIPT>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    where does it give that error?

    Comment

    • jmarcrum
      New Member
      • Oct 2007
      • 105

      #3
      I created a page called test.shtml. The error is like this, "Last modified on undefined NaN, NaN"

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        Wrong board.

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          it looks like the creation of the Date object failed. what does document.lastMo dified give you?

          Comment

          • jmarcrum
            New Member
            • Oct 2007
            • 105

            #6
            nothing happened when i used document.lastMo dified. It was just a blank webpage. However, I changed browsers and it worked fine. I was using Google Chrome. The code works fine in IE or Firefox. Not sure why??

            Comment

            Working...