views:

2748

answers:

10

Is it possible for some Javascript to detect whether Skype is installed or not?

The reason I ask is that 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.

A: 

No, it's not generally possible to detect if skype or any other software is installed from a web page unless the app does something specific to make the information available like modify the user agent string a la .Net or you have a special browser extension,

Joel Coehoorn
Well, the question as I see it is whether there's anything able to cope with 'skype:' URLs. Which Skype will do, if it's installed. Which makes it relevant and possible.Still looking for a solution for Safari.
akauppi
A: 

That would not be what security policy of javascript wants.

Without a plugin or other third party stuff you never get such infos. You only can get informations of missing plugins but not missing software on your OS.

should also be problematic to get this working on mac&linux&windows at the same time.

joki
+6  A: 

Works in IE and Firefox, but not Chrome or Opera

function isSkypeInstalled(str) {
    try {
     /*@cc_on
     //The Microsoft way, thanks to the conditional comments only run in IE
     if (new ActiveXObject("Skype.Detection")) return true;
     @*/

     //Tested for firefox on win
     if (navigator.mimeTypes["application/x-skype"]) return true;
    }
    catch(e){}
    return false;
}
some
+5  A: 

According to skype, it might be possible:
http://www.skype.com/share/buttons/advanced.html#detection
although there seems to be a bit of noise in their forums about it being a bit buggy, and possibly neutered by recent security updates. Could be a good starting point though.

seanb
+3  A: 

The skype plugin for IE modifies the DOM so you can always have a 'dummy' phone number field somewhere and look out for any injected 'span' elements with classname 'skype_tb_injection'...

What you're looking for is something like this:

<SPAN onmouseup=".." class="skype_tb_injection" onmousedown="..." id="softomate_highlight_0" onmouseover="..." title="Call this phone number in Thailand with Skype: +66812341234" onclick="..." onmouseout="..." durex="0" context="+66 8 1234 1234" IamRTL="0">
  <SPAN class="skype_tb_nop">&nbsp;</SPAN>
  <SPAN onmouseup="..." class="skype_tb_imgA_flex" onmousedown="..." id="skype_tb_droppart_0" onmouseover="..." title="Skype actions" style="..." onclick="..." onmouseout="...">
    &nbsp;&nbsp;
    <SPAN class="skype_tb_nop">&nbsp;</SPAN>
    <SPAN class="skype_tb_imgFlag" id="skype_tb_img_f0" style="...">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>
    &nbsp;
    <SPAN class="skype_tb_nop">&nbsp;</SPAN>
  </SPAN>
  <SPAN class="skype_tb_imgS" id="skype_tb_img_s0" style="...">&nbsp;</SPAN>
  <SPAN class="skype_tb_injectionIn" id="skype_tb_text0" style="...">
    <SPAN class="skype_tb_innerText" id="skype_tb_innerText0"> +6...</SPAN>
  </SPAN>
  <SPAN class="skype_tb_imgR" id="skype_tb_img_r0" style="...">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <SPAN class="skype_tb_nop">&nbsp;</SPAN>
  </SPAN>
</SPAN>
KristoferA - Huagati.com
A: 

It might be worthwhile to write a signed java applet. That way you can at least get access to the OS and determine if Skype is installed that way. Otherwise, as noticed, Javascript doesnt allow that sort of thing (if it did, your computer would of been compromised already).

that's a bit of overkill for my purposes, really. thanks for the answer though.
nickf
Also, its extremely common to *not* have java applet support. ( amd64 linux is generally this way, unless you're one of the rarities running IcedTea, and skype *does* work on linux. )
Kent Fredric
nickf - i suggest you read up on javascript some more.kent - yea a lot of things dont work for amd64 linux
+2  A: 

sounds like you're coding yourself into a bit of a corner there.. trying to detect skype with JS, running out of screen real estate.

the whole thing might be friendlier if instead, the "Contact" link takes the user to a contact page, with your "skype:" links and your explanatory skype-download content. it'll be a bunch more useful than a JS popup.

you could add some prefs, like an "i have skype don't show this page again" checkbox to this page. Then use that pref to toggle your "Contact" link.

nailitdown
+15  A: 

Thanks for the answers everyone: from the links and methods seanb and some posted, I was able to come up with a solution which works for IE and Firefox, so I thought I'd post a 'complete' answer. Here it is as a handy jQuery extension!

The jQuery Extension

jQuery.extend({
    skype : function(failureFunction) {
        var $ = jQuery;

        if ($.browser.safari || $.browser.opera) {
            return true;
        } else if ($.browser.msie) {
            try {
                if (new ActiveXObject("Skype.Detection")) return true;
            } catch(e) { }
        } else {
            if (typeof(navigator.mimeTypes["application/x-skype"]) == "object") {
                return true;
            }
        }
        $('a[href^="skype:"]').click(function() {
            failureFunction();
            return false;
        });
        return false;
    }
});

Usage

HTML:

<a href="skype:your.skype.username?call">Call me</a>
<a href="skype:your.skype.username?add">Add me</a>

Javascript:

jQuery(function($) {
    $.skype(function() {
        // this function gets called if they don't have skype.
        alert("Looks like you don't have skype. Bummer.");
    });
});

And that's it!

If someone using Safari, Opera or Chrome comes along, it'll just let the browser deal with it.

edit: rejigged the function so that it only performs the check when the page loads, not each time the page is loaded. The $.skype function will now return a bool telling you if skype was detected or not.

nickf
A: 

You can use the W3C standard and the browser will determine which software is installed to manage calls:

<a href="callto:<phone_number>"><phone_number></a>
gu
Well, this does not work if we want a Skype call instead of a usual numbered one.
akauppi
A: 

I was just testing in my Fedora 12, Linux platform using firefox or other browser does not work skype protocol.

Even having linux skype installed.

N.B: Above references are good for Windows platform

Stackfan