Domanda

I am developping an extension using Crossrider. I want in a specific webpage of my website to check if my extension is installed or not. The isAppInstalled method of crossrider is designed to show a message. However, I want it in stead to redirect to a page ( example : installed.html ) if the app is installed and to redirect to not.html if the app is not installed. Here is the sample of the code http://crossrider.com/demo/isAppInstalled.html I tried to play with the code to change it but my attempts were not successful. Can anyone show me where to insert the Javascript redirect to code in the following part :

$('#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'});
È stato utile?

Soluzione

In general, any action you want to perform once it has been determined whether the extension is installed should be placed in the Crossrider.isAppinstalled callback function. So in your case your code would look something like the following:

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
        }
    });
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top