PDA

View Full Version : Code to display a message if executed after a certain date?



NGJ
01-19-2006, 05:45 PM
Hi,

I want to put a time limit on accessing certain pages of an internal company website. e.g. If a certain date is reached then the user is prompted to contact me for an updated link - rather than possibly viewing out of date information.

I guess what I need is code to do a date check & then either direct the user to the right page or display a message.

Can anyone help please?

Twey
01-19-2006, 06:10 PM
If a certain date is reached then the user is prompted to contact me for an updated link - rather than possibly viewing out of date information.This should never be needed. Out-of-date pages you still want to keep around should be archived neatly and replaced. To use a script for this purpose would indicate neglect and bad design by the webmaster (presumably you).

NGJ
01-20-2006, 10:34 AM
Twey,

I appreciate your comments re keeping things tidy. However, the scenario I'm faced with relates to a number of different users, within my company, accessing the same 'supplier pricing' page(s).

In this specific case, I need to be able to specify a date that creates an event. This event will give certain users (they know who they are!) the option to go to a "head's-up" page with business related rebate info. It's important that this trigger happens when I need it to.

Thanks again, in advance, for your help in suggesting code for this.

Twey
01-20-2006, 05:01 PM
Very well.

function checkDateExceeded(expires, func) {
// expires is a string in MM/DD/YYYY format
// func is a function object to call
var now = new Date();
if(now.getTime() >= Date.parse(expires)) func();
}

NGJ
01-21-2006, 02:24 PM
Thank you - I'll give it a whirl !!

I'll be back soon with another one no doubt .... it's all a far cry from my old days of Modula2, Turbo Pascal & Cobol ... bit I'm getting there! ;)

Cheers,

N.

Twey
01-21-2006, 02:28 PM
Actually, I made an error. Edited.