从浏览器检测是否存在特定的应用程序安装 [英] Detect from browser if specific application is installed
问题描述
我们有一种先进的网页(ASP.NET中,C#),并且其需要在客户端计算机上安装,以利用所述网页以最充分一个应用。该应用程序是一个托盘的应用程序,并具有主要两个任务。检测时某些事件发生在网络服务器(例如邀请去参加一个会议,或通知即将到来的会议)。其他任务trayapp已经是使用自定义的协议(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建议的东西(我发现它这里和有没有测试过):
Another approach for IE is something similar to what JohnFx suggested (I found it here and have not tested it):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Internet
Settings\User Agent\Post Platform
这篇关于从浏览器检测是否存在特定的应用程序安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!