检查客户端计算机上是否安装了 adobe reader

发布于 2024-08-11 00:45:49 字数 335 浏览 11 评论 0原文

目前我正在开发一个网页,它将告诉用户客户端计算机上的某些配置。除此之外,还需要检测客户端计算机上是否安装了 Adob​​e Reader。我正在使用 ASP.NET/C#。

我查看了以下网址寻找答案 “检查 Adob​​e Reader 是否已安装 (C#)?”,但代码会查看服务器注册表位于安装 IIS 的位置,而不是运行浏览器的客户端计算机。

是否可以检测 Adob​​e reader 是否安装在客户端计算机上而不是托管网站的服务器上?

Currently I am working on a web page which will tell user about certain configurations on client machine. Out of this there is also requirement of detecting if Adobe Reader is installed on client machine or not. I am using ASP.NET/C#.

I have looked the following url for the answer
"Check Adobe Reader is installed (C#)?" but the code look into the server registry entires where IIS is installed and not the client machine where browser is running.

Is it possible to detect if Adobe reader is installed on client machine and not the server which is hosting the website?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

塔塔猫 2024-08-18 00:45:49

请检查下面的脚本,它在 IE、FireFox 和 Chrome 中对我来说运行良好,

<html>
<body>
<script type="text/javascript">
var found = false;
var info = '';

try 
{    
    acrobat4 = new ActiveXObject('PDF.PdfCtrl.1');    
    if (acrobat4) 
    {      
        found = true;      
        info = 'v. 4.0';    
    }  
}  
catch (e) 
{
    //???
}

if (!found)
{
    try 
    {
        acrobat7 = new ActiveXObject('AcroPDF.PDF.1');
        if (acrobat7) 
        {
            found = true;
            info = 'v. 7+';
        }
    } 
    catch (e) 
    {
        //???
    }

    if (!found && navigator.plugins && navigator.plugins.length>0)
    {
        for (var i = 0; i<navigator.plugins.length; i++) 
        {                           
            if (navigator.plugins[i].name.indexOf('Adobe Acrobat') > -1)
            {
                found = true; 
                info = navigator.plugins[i].description + ' (' + navigator.plugins[i].filename + ')';
                break;
            }
        }
    }
}

document.write("Acrobat Reader Installed : " + found);
document.write("<br />");
if (found) document.write("Info : " + info);
</script>
</body>
</html>

希望这有帮助,问候

pls, check the script below, it worked fine for me in IE, FireFox and Chrome

<html>
<body>
<script type="text/javascript">
var found = false;
var info = '';

try 
{    
    acrobat4 = new ActiveXObject('PDF.PdfCtrl.1');    
    if (acrobat4) 
    {      
        found = true;      
        info = 'v. 4.0';    
    }  
}  
catch (e) 
{
    //???
}

if (!found)
{
    try 
    {
        acrobat7 = new ActiveXObject('AcroPDF.PDF.1');
        if (acrobat7) 
        {
            found = true;
            info = 'v. 7+';
        }
    } 
    catch (e) 
    {
        //???
    }

    if (!found && navigator.plugins && navigator.plugins.length>0)
    {
        for (var i = 0; i<navigator.plugins.length; i++) 
        {                           
            if (navigator.plugins[i].name.indexOf('Adobe Acrobat') > -1)
            {
                found = true; 
                info = navigator.plugins[i].description + ' (' + navigator.plugins[i].filename + ')';
                break;
            }
        }
    }
}

document.write("Acrobat Reader Installed : " + found);
document.write("<br />");
if (found) document.write("Info : " + info);
</script>
</body>
</html>

hope this helps, regards

白馒头 2024-08-18 00:45:49

我使用了这个脚本并在就绪函数上调用它:
注意:我在这里使用警报只是为了知道如何使用它。

 <script type="text/javascript">
     $(document).ready(function () {
         alert(getAcrobatInfo().browser);
         alert(getAcrobatInfo().acrobat === "installed");
         alert(getAcrobatInfo().acrobatVersion);
     });


     var getAcrobatInfo = function () {

         var getBrowserName = function () {
             return '<%=Session["browser"].ToString()%>';
         };

         var getActiveXObject = function (name) {
             try { return new ActiveXObject(name); } catch (e) { }
         };

         var getNavigatorPlugin = function (name) {
             for (key in navigator.plugins) {
                 var plugin = navigator.plugins[key];
                 if (plugin.name == name) return plugin;
             }
         };

         var getPDFPlugin = function () {
             return this.plugin = this.plugin || function () {
                 if (getBrowserName() == 'ie' || getBrowserName().toLocaleLowerCase() == 'internetexplorer') {
                     //
                     // load the activeX control
                     // AcroPDF.PDF is used by version 7 and later
                     // PDF.PdfCtrl is used by version 6 and earlier
                     return getActiveXObject('AcroPDF.PDF') || getActiveXObject('PDF.PdfCtrl');
                 }
                 else {
                     return  getNavigatorPlugin('Adobe Acrobat') || getNavigatorPlugin('Chrome PDF Viewer') || getNavigatorPlugin('WebKit built-in PDF') || getWebKitPlugin();
                 }
             }();
         };
         var getWebKitPlugin = function () {
             for (var key in navigator.plugins) {
                 var plugin = navigator.plugins[key];
                 if (plugin.name && plugin.name.substring(0, 6) == "WebKit" && (plugin.name.indexOf("pdf") != -1 || plugin.name.indexOf("PDF") != -1)) return plugin;
             }
         };
         var isAcrobatInstalled = function () {
             return !!getPDFPlugin();
         };
         var getAcrobatVersion = function () {
             try {
                 var plugin = getPDFPlugin();

                 if (getBrowserName() == 'ie' || getBrowserName().toLocaleLowerCase() == 'internetexplorer') {
                     var versions = plugin.GetVersions().split(',');
                     var latest = versions[0].split('=');
                     return parseFloat(latest[1]);

                 }
                 if (plugin.version) return parseInt(plugin.version);
                 return plugin.name


             }
             catch (e) {
                 return null;
             }
         }

         // The returned object
         return {
             browser: getBrowserName(),
             acrobat: isAcrobatInstalled() ? 'installed' : false,
             acrobatVersion: getAcrobatVersion()
         };
     };
</script>

另外在后面添加此代码:

  public void detectBrowser()
     { //Set the Browser session variable
       System.Web.HttpBrowserCapabilities browser = Request.Browser;
       Session["Browser"] = browser.Browser;
    }

希望有帮助。

I used this script and called it on ready function :
Note: i used the alerts here just to know how to use it.

 <script type="text/javascript">
     $(document).ready(function () {
         alert(getAcrobatInfo().browser);
         alert(getAcrobatInfo().acrobat === "installed");
         alert(getAcrobatInfo().acrobatVersion);
     });


     var getAcrobatInfo = function () {

         var getBrowserName = function () {
             return '<%=Session["browser"].ToString()%>';
         };

         var getActiveXObject = function (name) {
             try { return new ActiveXObject(name); } catch (e) { }
         };

         var getNavigatorPlugin = function (name) {
             for (key in navigator.plugins) {
                 var plugin = navigator.plugins[key];
                 if (plugin.name == name) return plugin;
             }
         };

         var getPDFPlugin = function () {
             return this.plugin = this.plugin || function () {
                 if (getBrowserName() == 'ie' || getBrowserName().toLocaleLowerCase() == 'internetexplorer') {
                     //
                     // load the activeX control
                     // AcroPDF.PDF is used by version 7 and later
                     // PDF.PdfCtrl is used by version 6 and earlier
                     return getActiveXObject('AcroPDF.PDF') || getActiveXObject('PDF.PdfCtrl');
                 }
                 else {
                     return  getNavigatorPlugin('Adobe Acrobat') || getNavigatorPlugin('Chrome PDF Viewer') || getNavigatorPlugin('WebKit built-in PDF') || getWebKitPlugin();
                 }
             }();
         };
         var getWebKitPlugin = function () {
             for (var key in navigator.plugins) {
                 var plugin = navigator.plugins[key];
                 if (plugin.name && plugin.name.substring(0, 6) == "WebKit" && (plugin.name.indexOf("pdf") != -1 || plugin.name.indexOf("PDF") != -1)) return plugin;
             }
         };
         var isAcrobatInstalled = function () {
             return !!getPDFPlugin();
         };
         var getAcrobatVersion = function () {
             try {
                 var plugin = getPDFPlugin();

                 if (getBrowserName() == 'ie' || getBrowserName().toLocaleLowerCase() == 'internetexplorer') {
                     var versions = plugin.GetVersions().split(',');
                     var latest = versions[0].split('=');
                     return parseFloat(latest[1]);

                 }
                 if (plugin.version) return parseInt(plugin.version);
                 return plugin.name


             }
             catch (e) {
                 return null;
             }
         }

         // The returned object
         return {
             browser: getBrowserName(),
             acrobat: isAcrobatInstalled() ? 'installed' : false,
             acrobatVersion: getAcrobatVersion()
         };
     };
</script>

Also add this code behind:

  public void detectBrowser()
     { //Set the Browser session variable
       System.Web.HttpBrowserCapabilities browser = Request.Browser;
       Session["Browser"] = browser.Browser;
    }

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文