从浏览器检测是否安装了特定的应用程序 [英] Detect from browser if specific application is installed

查看:64
本文介绍了从浏览器检测是否安装了特定的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个高级网页(ASP.NET、C#)和一个应用程序,需要在客户端计算机上安装该应用程序才能充分利用该网页.该应用程序是一个托盘应用程序,主要有两个任务.检测 Web 服务器上何时发生某些事件(例如,受邀参加会议或通知即将举行的会议).托盘应用程序的另一项任务是使用自定义协议 (trayapp://) 执行一些返回服务器的 ajax 调用.

We have an advanced webpage (ASP.NET, C#), and a application which needs to be installed on the client computer in order to utilize the webpage to its fullest. The application is a tray app, and has primarily two tasks. Detect when certain events happen on the webserver (for instance invited to a meeting, or notify of an upcoming meeting). The other task the trayapp has is to use a custom protocol (trayapp://) to perform some ajax calls back to the server.

我们遇到的一个问题是如何确定应用程序是否安装在本地机器上.现在,用户必须勾选一个复选框以通知网站应用程序已安装,并且可以安全地调用trayapp://url 调用.

One problem we have is how to determine if the application is installed on the local machine or not. Now the user has to tick a checkbox to inform the website that the application is installed, and that it's safe to call the trayapp:// url calls.

有什么办法,例如通过 JavaScript 或类似的方法来检测我们的应用程序是否安装在本地机器上?

Is there any way, for instance through a JavaScript or similar to detect if our application is installed on the local machine?

该检查需要适用于 IE、FF 和 Opera 浏览器.

The check needs to work for IE, FF and Opera browsers.

推荐答案

如果您想在浏览器中使用 javascript 进行检测,您可能可以使用集合navigator.plugins".它适用于 Firefox、Opera 和 Chrome,但不幸的是不适用于 IE.

If you want to detect with javascript inside the browser, you can probably use the collection "navigator.plugins". It works with Firefox, Opera and Chrome but unfortunately not with IE.

更新:在 FF、Opera 和 Chrome 中,您可以像这样轻松地进行测试:

Update: In FF, Opera and Chrome you can test it easily like this:

if (navigator.plugins["Adobe Acrobat"]) {
// do some stuff if it is installed
} else {
// do some other stuff if its not installed
}

更新#2:如果它是 IE 中的 ActiveX 对象,您可以使用以下方法测试它是否存在:

Update #2: If it is an ActiveX object in IE you can test if it exists by using something like this:

function getActiveXObject(name){
        try{
            return new ActiveXObject(name);
        }
        catch(err){
            return undefined;
        }
};

IE 的另一种方法类似于 JohnFx 建议的方法(我在 here 和没有测试过):

Another approach for IE is something similar to what JohnFx suggested (I found it here and have not tested it):

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurr entVersionInternet
SettingsUser AgentPost Platform

这篇关于从浏览器检测是否安装了特定的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆