The Blog of Ryan McNair

Javascript Year Script - Copyright update

Posted: April 8th, 2009 | Author: Ryan | Filed under: JavaScript | Tags: , , | 1 Comment »

Maintenance and Updatability of webpages are a high priority, with a little JavaScript your pages can be self-updating.

Create a new JavaScript file, call it jsyear.js and type the following code.

var theDate=new Date()

document.write(theDate.getFullYear())

Add the script to your footer

<div id=”footer”>&copy; Your Name 2000-<script type=”text/javascript” src=”jsyear.js”>, All rights Reserved</div>

This will call each time the page is loaded to get the current year and display the year in your footer, the script is useful were lots of pages have been created and the laborious task of correcting the year is needed.