Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1605 How can I supply different values to the location object's replace() method, perhaps based on the current date, by invoking a function?

irt.org | Knowledge Base | JavaScript | Misc | Q1605 [ previous next ]

Q1605 How can I supply different values to the location object's replace() method, perhaps based on the current date, by invoking a function?

Try the following:

<script language="JavaScript"><!--
function getPage() {
  var now = new Date();
  var year = now.getFullYear();
  var month = now.getMonth() + 1;
  var day = now.getDay();

  return 'http://www.somewhere.com/' + year + '/' + month + '/' + day + '/index.htm';
}
//--></script>

<a href="default.htm" onClick="location.replace(getPage());return false">replace</a>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.