这是Windows的。
我有一个闪存申请,我正在转换为空气。我使用NSIS构建了一个专用安装程序,它工作得很好。然而,我想在一个网站上有一个图标,检查应用程序是否已经安装,并询问用户是否希望运行它。如果没有安装,他们可以选择下载。
我相当肯定这是可行的,因为Zoom和GoToMeeting都是这样做的。
我的搜索技能似乎是失败的时候,我寻找这个。
编辑:
这样做的最佳/唯一方法似乎是为应用程序创建自定义协议。类似于DoDaApp://。
这就引出了下一步的问题;
发布于 2020-07-01 13:19:35
这是一个部分的答案,因为它不工作在边缘。我将在下面解释这个问题。
正如如何检测浏览器的协议处理程序中推荐的那样,您可以使用超时&模糊事件处理程序。这是我对守则的解释;
function checkCustomProtocol(inProtocol,inInstalLink,inTimeOut)
{
var timeout = inTimeOut;
window.addEventListener('blur',function(e)
{
window.clearTimeout(timeout);
}
)
timeout = window.setTimeout(function()
{
console.log('timeout');
window.location = inInstalLink;
}, inTimeOut
);
window.location = inProtocol;
}Microsoft通过弹出一个对话框告诉您“您将需要一个新的应用程序来打开这个程序”,它“模糊”屏幕,不允许下载该文件,这是非常有帮助的。
因此,我将发布另一个问题,如何使它在边缘工作。我已经回顾过ismailhabib码,但是已知的问题部分说它也不适用于边缘。
发布于 2020-07-01 13:57:03
这是一个更完整的答案。它已经在IE11,Microsoft,Chrome和Firefox上进行了轻微的测试。我还补充了一些意见;
/*
checkCustomProtocol - check if custom protocol exists
inProtocol - URL of application to run eg: MyApp://
inInstallLink - URL to run when the protocol does not exist.
inTimeOut - time in miliseconds to wait for application to Launch.
*/
function checkCustomProtocol(inProtocol,inInstalLink,inTimeOut)
{
// Check if Microsoft Edge
if (navigator.msLaunchUri)
{
navigator.msLaunchUri(inProtocol, function ()
{
//It launched, nothing to do
},
function()
{
window.location = inInstalLink; //Launch alternative, typically app download.
}
);
}
else
{
// Not Edge
var timeout = inTimeOut;
//Set up a listener to see if it navigates away from the page.
// If so we assume the papplication launched
window.addEventListener('blur',function(e)
{
window.clearTimeout(timeout);
}
)
//Set a timeout so that if the application does not launch within the timeout we
// assume the protocol does not exist
timeout = window.setTimeout(function()
{
console.log('timeout');
window.location = inInstalLink; //Try to launch application
}, inTimeOut
);
window.location = inProtocol; //Launch alternative, typically app download.
}
}https://stackoverflow.com/questions/62657154
复制相似问题