Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Misc | Q1605 [ previous next ]

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>

©2018 Martin Webb