6 Replies Latest reply on Nov 29, 2008 7:07 PM by George_Johnson

    Javascript window Title

    fjcunninghamjr Level 1
      Hi,
      I have spent some time with this scripting but can't get the cTitle to work. I am not sure where to place this command. This is my whole script. Everything works except the javascript windown does not list my title. Can someone help?

      function Expire(sExpirationDate, cFormat)
      {
      //Get the Current Date and Time value
      var Now = new Date();
      // Setup End Date
      var End = util.scand(cFormat, sExpirationDate);
      // Will return true if current date is after expiration
      return (Now > End);
      }
      // Set expiration date string format mm/dd/yyyy
      var cExpiration = "11/26/2008";
      // Execute check expiration code
      if (Expire(cExpiration, "mm/dd/yyyy"))
      {
      cTitle: "A message from Frank Cunningham";
      app.alert("THE USE OF THIS APPLICATION HAS EXPIRED! CALL FRANK CUNNINGHAM AT 610-xxx-xxxx FOR CONTINUED USE OF THIS FORM", 0);
      this.closeDoc();
      }

      Thank Frank
        • 1. Re: Javascript window Title
          George_Johnson MVP & Adobe Community Professional
          Do something like:


          app.alert({cMsg: "THE USE OF THIS APPLICATION HAS EXPIRED! CALL...", nIcon: 0, nType: 0, cTitle: "A message from..."});


          George
          • 2. Re: Javascript window Title
            fjcunninghamjr Level 1
            Hi,
            I have retyped the script to allow for the new format, but now get an missing ; before statement. I can't see it. Here is the new scripting:

            function Expire(sExpirationDate, cFormat)
            {
            //Get the Current Date and Time value
            var Now = new Date();
            // Setup End Date
            var End = util.scand(cFormat, sExpirationDate);
            // Will return true if current date is after expiration
            return (Now > End);
            }
            // Set expiration date string format mm/dd/yyyy
            var cExpiration = "11/26/2008";
            // Execute check expiration code
            if (Expire(cExpiration, "mm/dd/yyyy"))
            {
            FRANK CUNNINGHAM AT 610-xxx-xxxx FOR CONTINUED US OF THIS FORM,
            nIcon: 0, nType: 0, cTitle: A message from Frank Cunningham
            this.closeDoc();
            }
            • 3. Re: Javascript window Title
              George_Johnson MVP & Adobe Community Professional
              You left out the app.alert statement and a few other things associated with it. There are also a few nonstandard quote characters. Try this:


              function Expire(sExpirationDate, cFormat) {

                  //Get the Current Date and Time value
                  var Now = new Date();

                  // Setup End Date
                  var End = util.scand(cFormat, sExpirationDate);

                  // Will return true if current date is after expiration
                  return (Now > End);
              }

              // Set expiration date string format mm/dd/yyyy
              var cExpiration = "11/26/2008";

              // Execute check expiration code
              if (Expire(cExpiration, "mm/dd/yyyy")) {

                  app.alert({
                      cMsg: "FRANK CUNNINGHAM AT 610-xxx-xxxx FOR CONTINUED US OF THIS FORM",
                      nIcon: 0,
                      nType: 0,
                      cTitle: "A message from Frank Cunningham"
                  });

                  this.closeDoc();
              }


              George
              • 4. Re: Javascript window Title
                fjcunninghamjr Level 1
                Thanks George for all your help everything is now working great.

                One last question. Because I have an expiration date in the script, is there a way to advance the date every now and again when it expires without having the alter the system date on my computer to gain access to the Acrobat file?
                Frank
                • 5. Re: Javascript window Title
                  George_Johnson MVP & Adobe Community Professional
                  If you what you really want is to prevent the document from closing if the document is opened on your system, there are several approaches you can take. Probably the simplest is to add a test for a variable that you set up on your system in a folder-level JavaScript file or global variable. For example, if you could place the following in a folder-level JavaScript file:

                  var bDontClose = true;

                  and then modify the code above to be:

                  if (!bDontClose) this.closeDoc();

                  You and your users would still get the alert telling you the document has expired, but it wouldn't close for you. For your users, they would presumably not have this global variable defined (so it would be undefined) and the document would close.

                  George
                  • 6. Re: Javascript window Title
                    George_Johnson MVP & Adobe Community Professional
                    Oops, that's wrong. It should be:

                    if (typeof bDontClose == "undefined") this.closeDoc();

                    George