【问题标题】:Detect if extension is installed Crossrider API检测是否安装了扩展 Crossrider API
【发布时间】:2013-08-21 12:54:53
【问题描述】:

我正在使用 Crossrider 开发一个扩展。我想在我网站的特定网页中检查我的扩展程序是否已安装。 crossrider 的 isAppInstalled 方法旨在显示一条消息。但是,如果安装了应用程序,我希望它改为重定向到页面(例如: installed.html ),如果未安装应用程序,我希望它重定向到 not.html 。 这是代码示例 http://crossrider.com/demo/isAppInstalled.html 我尝试使用代码来更改它,但我的尝试没有成功。谁能告诉我在哪里插入 Javascript 重定向到以下部分的代码:

$('#statusMessage').html('The extension <span id="status">is' +
 ((!isInstalled) ? ' NOT' : '') + '</span> installed.' +
 ((!isInstalled) ? ' Please <a href="http:\//crossrider.com/download/' + appId + '">install</a> the extension and refresh this page.' : ''));
  $('#status').css({'color':(!isInstalled) ? 'red' : 'green', 'font-weight':'bold'});

【问题讨论】:

    标签: javascript google-chrome detect crossrider


    【解决方案1】:

    一般来说,一旦确定是否安装了扩展,您想要执行的任何操作都应该放在Crossrider.isAppinstalled 回调函数中。因此,在您的情况下,您的代码将如下所示:

    var appId = 'EXTN_ID'; // Replace this with the id of your extension
    $(function() {          
        // Call the isAppInstalled method
        CrossriderAPI.isAppInstalled(appId, function(isInstalled) {
            // Callback function                
            // isInstalled: true if the extension is installed; otherwise false
            if (isInstalled) {
                // Your code to redirect if extension is installed
            } else {
                // Your code to redirect if extension is NOT installed
            }
        });
    });
    

    【讨论】:

    • 嗨 Shlomo,我如何在安装过程中添加回调?我想在成功安装后提醒用户并重新加载他的页面。谢谢。
    猜你喜欢
    • 2015-03-11
    • 2013-05-17
    • 1970-01-01
    • 2011-06-03
    • 1970-01-01
    • 2012-03-07
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多