Welcome to TalkGraphics.com
Page 1 of 3 123 LastLast
Results 1 to 10 of 26
  1. #1

    Default Website shows when it was last updated (No input required)

    Put this code in a placeholder (body section) on any of your website pages and adjust the font color to what you want to. Upload your webpage and each time you do this then the date you modified the page is updated as well. No input required at all.

    <SCRIPT LANGUAGE="JavaScript">
    function Initialize()
    { this.length = Initialize.arguments.length
    for ( var i = 0; i < this.length; i++ ) this[ i + 1 ] =
    Initialize.arguments[ i ]
    }

    var DayOfWeek = new Initialize("Updated", "Updated", "Updated",
    "Updated", "Updated", "Updated", "Updated" );
    var MonthName = new Initialize("Jan", "Feb", "Mar", "Apr",
    "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
    "Dec");
    var LastModifiedDate = new Date(document.lastModified);

    document.write("<bold><font color=FFFFFF>");
    document.write(DayOfWeek[(LastModifiedDate.getDay() + 1 )] ,", ");
    document.write(MonthName[(LastModifiedDate.getMonth() + 1)] ," ");
    year=LastModifiedDate.getYear();
    if (year<100) year+=100;
    if (year<1000) year+=1900;
    document.write( LastModifiedDate.getDate() ,", " ,( year ) );
    hours= LastModifiedDate.getHours();
    document.write( " at ", ((hours < 10) ? "0" : "") + hours )
    minutes= LastModifiedDate.getMinutes();
    document.write( ((minutes < 10) ? ":0" : ":") + minutes );

    </SCRIPT>

  2. #2
    Join Date
    Mar 2009
    Posts
    4,503

    Default Re: Website shows when it was last updated (No input required)

    Thank you, I added the code to one of my websites.

  3. #3
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,858

    Default Re: Website shows when it was last updated (No input required)

    Jason, very useful coding.

    Would it not be more in keeping to use a DIV with an ID?
    <div id='lastModified'>&nbsp;</div>
    <script>
    document.getElementById('lastModified').innerHTML = document.lastModified;
    </script>
    I've only removed your date formatting to focus on the use of innerHTML rather than document.write.
    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  4. #4

    Default Re: Website shows when it was last updated (No input required)

    Brilliant, however, I figured out how to change the font colour, but is it possible to change the font and font size?

    Many thanks

  5. #5
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,858

    Info Re: Website shows when it was last updated (No input required)

    Quote Originally Posted by Teeser View Post
    Brilliant, however, I figured out how to change the font colour, but is it possible to change the font and font size?
    Many thanks
    Create a Text Line. type any gibberish or "Page Modified on Date/Time".
    Apply any text colour, font and size.

    Change to the Select tool and select the line.
    In Utilities > Names, add HTMLBlockText and lastModified to the Name properties.
    In its Placeholder HTML code (body), add:
    <script>
    document.getElementById('lastModified').innerHTML = document.lastModified;
    </script>
    Thios is why I prefer using innerHTML.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  6. #6

    Default Re: Website shows when it was last updated (No input required)

    Hi Acorn, brilliant.
    But, I'm in the UK, can we swap the month and day round please? so it's DD / MM / YEAR

    Many thanks

  7. #7
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,858

    Default Re: Website shows when it was last updated (No input required)

    Quote Originally Posted by Teeser View Post
    Hi Acorn, brilliant.
    But, I'm in the UK, can we swap the month and day round please? so it's DD / MM / YEAR

    Many thanks
    You then need to put back all the JavaScripting Jason provided but against a variable that holds document.lastModified.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  8. #8
    Join Date
    Mar 2009
    Posts
    4,503

    Default Re: Website shows when it was last updated (No input required)

    Quote Originally Posted by Teeser View Post
    But, I'm in the UK, can we swap the month and day round please? so it's DD / MM / YEAR
    <SCRIPT LANGUAGE="JavaScript">
    function Initialize()
    { this.length = Initialize.arguments.length
    for ( var i = 0; i < this.length; i++ ) this[ i + 1 ] =
    Initialize.arguments[ i ]
    }

    var DayOfWeek = new Initialize("Updated", "Updated", "Updated",
    "Updated", "Updated", "Updated", "Updated" );
    var MonthName = new Initialize("Jan", "Feb", "Mar", "Apr",
    "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
    "Dec");
    var LastModifiedDate = new Date(document.lastModified);


    document.write("<bold><font color=000000>");
    document.write(DayOfWeek[(LastModifiedDate.getDay() + 1 )] ,": ");
    document.write( LastModifiedDate.getDate() ," " );
    year=LastModifiedDate.getYear();
    if (year<100) year+=100;
    if (year<1000) year+=1900;document.write(MonthName[(LastModifiedDate.getMonth() + 1)] ," ",( year ) );


    hours= LastModifiedDate.getHours();
    document.write( " at ", ((hours < 10) ? "0" : "") + hours )
    minutes= LastModifiedDate.getMinutes();
    document.write( ((minutes < 10) ? ":0" : ":") + minutes );

    </SCRIPT>

  9. #9
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,858

    Info Re: Website shows when it was last updated (No input required)

    @Boy, I think you've missed my point about the use of innerHTML allowing a more flexible (Xara) way of adding font effects.

    @Teeser For a UK date, try:

    <script>
    var dateString;
    var newDate;

    dateString = document.lastModified;
    newDate = dateString.substr(3,3) + dateString.substr(0,3) + dateString.substr(6);

    document.getElementById('lastModified').innerHTML = newDate;
    </script>
    The last substr(6) can be substr(8) instead to remove the Century.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  10. #10
    Join Date
    Mar 2009
    Posts
    4,503

    Default Re: Website shows when it was last updated (No input required)

    Quote Originally Posted by Acorn View Post
    @Boy, I think you've missed my point about the use of innerHTML allowing a more flexible (Xara) way of adding font effects.

    @Teeser For a UK date, try:



    The last substr(6) can be substr(8) instead to remove the Century.

    Acorn
    Acorn, I hadn't really looked at your code until now. I'm a bit confused by it. So what does your code look like, I mean altogether?

 

 

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
  •