Re: Date Expiry of Page using Javascript ?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Date Expiry of Page using Javascript ?

From: alu <none@none.com>
Date: Fri Jul 29 2005 - 16:58:38 CEST

<ianv2@aol.com> wrote in message
> Hi
>
> Is the following possible using Javascript ?
>
> I would like a page to redirect to another page if the page expiry has
> passed.
>
> E.G.
>
> If my questionnaireform.html page had an expiry date of July 31, if I
> tried to access that page after this date (i.e. August 1st) I would be
> redirected to index.html.
>
> Is this possible?

________________________________

quickly modified from Don Demrow's script at
http://javascript.internet.com/calendars/auto-expire.html

<body>

<script type="text/javascript">

// Set the expiry date below
var expireDate = "20050731";

var expireYear = expireDate.substring(0,4)
var expireMonth = expireDate.slice(4,-2)
var expireDay = expireDate.slice(6)
var nowDate = new Date();
var day = nowDate.getUTCDate();
var month = nowDate.getUTCMonth();
var month1 = month + 1;
  if (month1 < 10)
  {
  month1 = "0" + month1;
  }
  if (day < 10)
  {
  day = "0" + day;
  }
var year = nowDate.getUTCFullYear();
var GMTdate = year + "" + month1 + "" + day

if (GMTdate > expireDate) {location.href = "index.html"}

</script>

still questionnaireform.html

</body>

________________________________

-alu
Received on Tue Oct 18 03:03:30 2005