Article From:https://www.cnblogs.com/zhixi/p/9969219.html

Recently, we need to implement a function of clicking buttons to call local applications in PC web pages.

In fact, the principle of implementation is very simple.

First register a local registry file to point to the local application path

Secondly, using JS to point to the registry file in the web page, we can call the local application on the web page.

Windows Registry Editor Version 5.00



[HKEY_CLASSES_ROOT\myprotocol]

@="myprotocol Protocol"

"URL Protocol"=""



[HKEY_CLASSES_ROOT\myprotocol\DefaultIcon]

@="D:\\Tools\\FF\\tencent\\qqmusic\\QQMusic.exe"



[HKEY_CLASSES_ROOT\myprotocol\shell]

@=""



[HKEY_CLASSES_ROOT\myprotocol\shell\open]

@=""



[HKEY_CLASSES_ROOT\myprotocol\shell\open\command]

@="\"D:\\Tools\\FF\\tencent\\qqmusic\\QQMusic.exe\" "
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body style="text-align: center;padding-top: 300px;">
<button onclick="window.location.href='myprotocol://D:\\work\\data\\2018\\08-11\\11-16\\myprotocol.reg'" style="margin: 200px auto;">Open QQ music</button>
<a href="myprotocol://D:\work\data\2018\08-11\11-16\myprotocol.reg" style="margin: 200px auto;">Open QQ music</a>
</body>
</html>

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *