Automatically Update Site Copyright Notice
I recently realized that I had forgotten to change the copyright notice on some of my websites. I had changed it on all of my still and video cameras and in the metadata fields for Breeze Downloader Pro and Adobe Lightroom; I had even changed it on some of my websites. But somehow I missed a couple.
Instead of just fixing it now for the sites that I missed in January, I wrote some Javascript code to do it automatically based on the year. You can see the resulting text in the Copyright Notice for this site at the bottom of the right sidebar.
Here’s what the code looks like. Note that it automatically updates the year and it links to your email address from your name (in a method very unfriendly to spam harvesters). If you want to use it simply copy and paste into a widget or into your wordpress header or footer and it will start displaying.
NOTE – You must to update the 3 “var” fields to ensure that the code uses your own Name and Email address.
<script language="Javascript">
var name = "Test User"
var account = "user"
var domain = "testsite.com"
var mydate = new Date()
var year = mydate.getFullYear()
document.write("©" + year + ", <a class=link href='mailto:" + account + "@" + domain + "'>" + name + "</a>")
</script>
<br>All Rights Reserved
If you want to use this code in a post or a page then it will be much more difficult to make it work. You will have to refer to the WordPress Codex for information on how to use Javascript in a post or a page.
Related Posts
3 Comments »
RSS feed for comments on this post. TrackBack URL


If you are unable or unwilling to add Java to your site, but are using PHP (e.g. WordPress), there is another approach that works well. Simply use PHP directives to create the year reference and add a line as follows into your page footer (or wherever):
Copyright © 2007- All Rights Reserved.
The Java email link is a cool trick.
Hmmm…
Looks like the php code got filtered out.
Here is a munged version of the php code:
Copyright [ampersand]copy; 2007-[open_angle]?php echo date(‘Y’);?[close_angle] All Rights Reserved.
In real life you’d need to substitute what is stated in the square brackets with the named symbol.
Hope this is clearer!
Thanks Dave, that’s another great trick!