Javascript Expire Code
I have been using a Expire Code someone provided to me from this site. Works great. The thing I've noticed is that when I apply the code to a multi-page doc the code doesn't close the doc. Instead an alert window pops open stating the expiration date has passed. There's a "OK" option to click. Then another window pop open asking "Don't save, Cancel, or Save". If I click Don't Save, the doc closes. If I click Save a window pops open asking where to save the doc to. But, if I click Cancel the doc stays open and the Expire Code is defeated. The user then has complete access. If they save their work they'll still get the Expire window, but nonetheless, they'll be able to continue using my work.
When I apply the Expire Code to a single page doc the code shuts down right on time the way I want. But not when it comes to a multi-page doc. Can someone shed some light as to what is going on with the code and possibly help me correct it so it will work on a multi-page doc. Here's the script I've been using, please take a look and let me know. Thanks.
function Expire()
{
// Get the current date and time
var rightNow = new Date();
// Setup End Date
var rightNow = new Date();
var beginDate = new Date("December 5, 2012 06:15:00 AM");
var endDate = new Date("June 16, 2013 1:57:00 PM");
if (rightNow < beginDate || rightNow > endDate)
{
app.alert("It has past the time limit. You cannot use this document any further.\n___________________________________________\n\nContact me to continue using this document. Thanks.", 0, 0);
this.closeDoc()
}
}
// execute check expiration code
Expire();
jackson chaker