5 Replies Latest reply on Feb 19, 2007 7:10 AM by insuractive

    install adobe reader

    tapping
      Before a user logs in to my web application, I need to check to see if they have Adobe Reader installed and then redirect the user to the adobe site to download adobe reader. Do you know of a script that I can use to check for the existence of Adobe Reader?


      Thank you for your time.


        • 1. Re: install adobe reader
          insuractive Level 3
          I did a google search for "javascript detect acrobat" and got about a bazillion results back. It looks like there is a few good scripts in this thread:

          http://www.oreillynet.com/cs/user/view/cs_msg/4055
          • 2. Re: install adobe reader
            tapping Level 1
            Thank you, Michael. I found the following code. Where would I put the code to get this to work in my application. How would I call the function?


            THank you.
            • 3. Re: install adobe reader
              insuractive Level 3
              I would suggest placing the script in the <head> of your login page. You can call the function when a client tries to submit the login form (onSumbit), then display a message to the user if they don't have acrobat. If you use the JavaScript confirm() method, you could raise and alert and have javascript redirect the client to adobe's site if they click "OK". One thing to watch out for is clients who have turned off javascript in their browsers. In that case, I would put a <noscript> block explaining that javascript is required to access the site.

              Hope that helps!
              • 4. Re: install adobe reader
                tapping Level 1
                I put the javascript code below in the head of the document:

                function checkadobe() {
                var acrobat=new Object();

                acrobat.installed=false;
                acrobat.version='0.0';

                if (navigator.plugins && navigator.plugins.length)
                {
                for (x=0; x {
                if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1)
                {
                acrobat.version=parseFloat(navigator.plugins[x].description.split('Version ')[1]);

                if (acrobat.version.toString().length == 1) acrobat.version+='.0';

                acrobat.installed=true;
                break;
                }
                }
                }
                else if (window.ActiveXObject)
                {
                for (x=2; x<10; x++)
                {
                try
                {
                oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
                if (oAcro)
                {
                acrobat.installed=true;
                acrobat.version=x+'.0';
                }
                }
                catch(e) {}
                }

                try
                {
                oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
                if (oAcro4)
                {
                acrobat.installed=true;
                acrobat.version='4.0';
                }
                }
                catch(e) {}

                try
                {
                oAcro7=new ActiveXObject('AcroPDF.PDF.1');
                if (oAcro7)
                {
                acrobat.installed=true;
                acrobat.version='7.0';
                }
                }
                catch(e) {}

                }

                if (acrobat.installed == true) {
                alert("Adobe reader is installed!")
                }
                }

                I called the function from onSubmit as follows:

                onSubmit="checkadobe();"

                I put the code in the login page, but nothing happens. I do not get the message that Adobe reader is installed. Could you look at this code and see where there is a problem?
                • 5. Re: install adobe reader
                  insuractive Level 3
                  There was a syntax problem in one of the loops in the code you provided. I fixed it, and set up the code below in a format that would probably work a little better for you. In the example below, the alert occurs if acrobat is not installed and it prevents the form from submitting. If you are testing on a machine with acrobat already installed, you can reverse the test (have it alert if acrobat IS installed) by changing the code: acrobat.installed == false to acrobat.installed == true