SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Safari problem

  1. #1
    SitePoint Enthusiast felix08's Avatar
    Join Date
    Mar 2008
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Safari problem

    Hello,
    I am having trouble getting this script to work in Mac OSX Safari but it works in everything else. Any suggestions.

    <script language="javascript" type="text/javascript">
    <!-- Begin
    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 lmonth = months[dateObj.getMonth() + 1]
    var date = dateObj.getDate()
    var fyear = dateObj.getYear()
    if (fyear < 2000)
    fyear = fyear + 1900
    document.write(lmonth + " " + date + ", " + fyear)
    // End -->
    </script>

    Any help is much appreciated.

    Sincerely,
    JavaScript Rookie
    Kimberly Kruse
    Graphic Designer/Web Designer

  2. #2
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    If anything isn't going to work, it would be the 'document.lastModified'

    Have you tried running it in Firefox and looking at the error console? It's pretty strict and will pop up any possible warnings or errors. That may give you some insight into the problem.

  3. #3
    SitePoint Enthusiast felix08's Avatar
    Join Date
    Mar 2008
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.lastModified

    You were right, it is the document.lastModified. It is not DOM compliant. Is there an alternative to using document.lastModified in this case?
    Kimberly Kruse
    Graphic Designer/Web Designer

  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Safari does support document.lastModified. However, the property relies on the server providing the details. Opening the file locally produced an empty string for the property while opening it via http worked. You may find that if you upload the test page to another server, it will work from there.

    In case you didn't know: your month array could be set up with a literal:
    Code:
    months = ["", "Jan", "Feb", ...]


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •