0

I'd like to change a link's href based on that: if Skype isn't installed, show a popup explaining what Skype is and how to install it, if it is installed, change the link to skype:my.contact.name?call so the click will start a call. Real estate issues means that I'd prefer to only have one link shown.

sdsdsd
  • 1
  • 1
  • possible duplicate of [Javascript to detect Skype?](http://stackoverflow.com/questions/358397/javascript-to-detect-skype) – Mikko Ohtamaa Jul 27 '13 at 08:51

2 Answers2

0

Unfortunately, browsers do not support such API and this cannot be done cross-browser compatible way. There is some kind of support, but it is buggy.

Javascript to detect Skype?

Community
  • 1
  • 1
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
0

All browser plugins registering their mime-types in global array named mimeTypes, that can be accessed via navigator object navigator.mimeTypes.

So you can use this for check plugin active or not. If plugin installed and disabled — no any mime-type will be registred for that disabled plugin. If plugin installed and active — he has a mime-type record in navigator.mimeTypes

Some code implementation using jQuery:

jQuery.extend({checkPlugin: function(mimetype_substr) {
    for (var i = 0; i < navigator.mimeTypes.length; i++) {
        if (navigator.mimeTypes[i]['type'].toLowerCase().indexOf(mimetype_substr) >= 0) {
                console.log("Gotcha! Here it is: "+navigator.mimeTypes[i]['type']);
                return true;
        }
    }
    return false;
}});

So this: $.checkPlugin("skype"); returns true if skype click2call plugin is installed and active. And false if there is no active plugin or plugin are not installed.

Actually need to search within another global array — navigator.plugins, but all active plugins have their records in navigator.mimeTypes, and this is a bit easier.