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>
Re: Website shows when it was last updated (No input required)
Thank you, I added the code to one of my websites.
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?
Quote:
<div id='lastModified'> </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
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
Re: Website shows when it was last updated (No input required)
Quote:
Originally Posted by
Teeser
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:
Quote:
<script>
document.getElementById('lastModified').innerHTML = document.lastModified;
</script>
Thios is why I prefer using innerHTML.
Acorn
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
Re: Website shows when it was last updated (No input required)
Quote:
Originally Posted by
Teeser
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
Re: Website shows when it was last updated (No input required)
Quote:
Originally Posted by
Teeser
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>
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:
Quote:
<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
Re: Website shows when it was last updated (No input required)
Quote:
Originally Posted by
Acorn
@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?