Check in browser is torrent-client installed

拥有回忆 提交于 2019-12-13 07:05:24

问题


Is there a way in javascript to check if magnet link is supported by browser (= to check if torrent client is installed on user's pc)?

I want to check via javascript if browser opens torrent client by clicking on magnet link or I need to show some additional instructions (if torrent client is not installed).


回答1:


Being a Browser, it has no access to installed applications in the OS, but what it does have is access to a list of supported MIME types.

In JavaScript you can check it as follows:

var mimeCheck = function (type) {
    return Array.prototype.some.call(navigator.plugins, function (plugin) {
        return Array.prototype.some.call(plugin, function (mime) {
            return mime.type == type;
        });
    });
};

Thanks to this previously asked question.

Here is a fiddle The MIME type I use is application/x-bittorrent

EDIT: As pointed out by @HaukurHaf, this will only work if the client has an extension installed for torrents in the browser itself. So this might or might not return true for some clients.




回答2:


No, not with javascript. Imagine if plain javascript could check what software users have installed on their machines. That would be a huge security risk.



来源:https://stackoverflow.com/questions/34044773/check-in-browser-is-torrent-client-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!