a better way to detect Java WebStart

So, just as I wrote that I wouldn't be posting much in future, I thought I would quickly post this little tidbit. There are various ways described online that you can use to detect if a client has Java WebStart installed. The problem is all of them require you to mix in VBScript for Internet Explorer and then use Javascript for the other browsers. There is a way you can support Internet Explorer and still use only Javascript. Check it out:

function jwsInstalled() {     
      // For Internet Explorer.
      if (navigator.userAgent.indexOf('MSIE') > -1) {
          try {
              var jws = new ActiveXObject('JavaWebStart.isInstalled');
              return true;
          }
          catch (e) {
              return false;
          }
      }

      // Firefox is happy with "x-java-jnlp-file". For Chrome and Safari
      // this does not work, instead I just check for "x-java-vm".
      // If they have a recent JVM installed, then they usually also have
      // Java WebStart installed.
      return navigator.mimeTypes &&
             navigator.mimeTypes.length &&
                 (navigator.mimeTypes['application/x-java-jnlp-file'] != null ||
                  navigator.mimeTypes['application/x-java-vm'] != null);
}

I use this to popup a little dialog and tell users to download a new JRE if Java WebStart is not installed. It works pretty well. And yes, it's 2009 and I'm still using Java WebStart ... although I do have a good reason for it. :-)