3

バージョン8以降、AdobeReaderプラグインの名前が「FirefoxおよびNetscape用のAdobePDFプラグイン」に変更され、バージョン情報が含まれていないことを知っています。ただし、Firefoxアドオンを表示すると、バージョン情報は[プラグイン]タブに表示されます。その情報がどこから来ているのか、JavaScriptでその値にアクセスできるかどうかを誰かが知っていますか?

Adobeはバージョン8と9の間でAcrobatReaderに大幅な変更を加えたため、IE以外のブラウザーで2つのバージョンを区別する方法がないとは信じがたいです。

4

2 に答える 2

2

すべての主要なブラウザでバージョン8と9を区別する必要がありますが、現在使用しているコードは、IEのすべてのバージョン、およびFirefox、Safari、Chromeの8までのすべてのバージョンで機能します。また、プラグインがインストールされているかどうかを検出しますが、Firefox、Safari、およびChromeのバージョン8以降のバージョン情報は検出しません。

var isInstalled = false;
var version = null;
var versionMessage = "";

if (window.ActiveXObject)
{
    var control = null;
    try
    {
        // AcroPDF.PDF is used by version 7 and later
        control = new ActiveXObject('AcroPDF.PDF');
    }
    catch (e)
    {
        // Do nothing
    }

    if (!control)
    {
        try
        {
            // PDF.PdfCtrl is used by version 6 and earlier
            control = new ActiveXObject('PDF.PdfCtrl');
        }
        catch (e)
        {
            // Do nothing
        }
    }

    if (control)
    {
        isInstalled = true;
        version = control.GetVersions().split(',');
        version = version[0].split('=');
        version = parseFloat(version[1]);
    }
    if (isInstalled)
    {
        if (version >= 9.0)
        {
            alert("You are using Adobe Reader "+ version +". You may continue.");
        }
        else
        {
            alert("You are using Adobe Reader "+ version +". You must download Adobe Reader 9 to continue.");
        }
    }
}
else
{
    for(var i = 0; i < navigator.plugins.length; i++)
    {
        if(navigator.plugins[i].name == "Adobe Acrobat")
        {
            isInstalled = true;

            if(navigator.plugins[i].description == "Adobe PDF Plug-In For Firefox and Netscape")
            {
                versionMessage = "You are using at least version 8 of Adobe Reader. If you cannot see any of the PDF's listed on this page, you may need to upgrade to version 9.";
            }
            else
            {
                versionMessage = "You are using a version of Adobe Reader that is not supported. You must download Adobe Reader 9 to continue.";
            }
        }
    }
    if (isInstalled)
    {
        alert(versionMessage);
    }
}
于 2010-02-22T15:07:03.137 に答える
0

IEおよびFFのすべてのバージョンでAcrobatを検出するコードを次に示します。重要なのは、以下を使用してバージョンを検出することです。

oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
if (oAcro)
{
acrobat.installed=true;
acrobat.version=x+'.0';
}

したがって、少しカスタマイズするだけで、バージョンを検出するために同様のものを使用できます。

完全なコードは次のとおりです。

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) {}

}

詳細については、 http://www.oreillynet.com/cs/user/view/cs_msg/4055を参照してください。

于 2010-02-17T14:57:03.313 に答える