How To Tell Whether a Protocol is Valid In Javascript

1.3k views Asked by At

Possible Duplicate:
How to detect browser's protocol handlers?

A certain software (non-browser based) installs a custom protocol when it is installed. Thus, if the software is installed on the system, putting a link that looks like

<a href="mycustomprotocol:///foobar">Launch the program!</a> 

in a web page launches the software when clicked (after putting up a warning of course).

If the software is not installed I want to dynamically change the element so that the browser does not try to launch it.

Is there a way in javascript to detect whether a protocol is valid? Would like it to work in at least Firefox, IE, Chrome and Safari.

Thanks

3

There are 3 answers

0
Kon On BEST ANSWER

There is no way for JavaScript to access a user's desktop file system or registry to validate a custom protocol.

0
James Miller On

You can try catching the error in the window.onError event or a.onError event if supported, then instead use javascript to navigate to the fall-back url.

0
Martin Jespersen On

All you have access to in javascript is navigator.plugins which will tell you what plugins are installed. The problem with this is, that the browser will pass the protocol onto the OS for handling if it doesn't know how to handle it itself, and you cannot via javascript find all the different protocol handlers the OS has installed.

So in other words: No...