需求描述:
在网站页面上点击一个按钮或者链接,能够调取本地的EXE程序,比如本地记事本。
实现思路:
1.首先我们选用windows系统的记事本程序NOTEPAD.EXE
2.编写一个.reg注册表,将其导入到注册表中。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\myprotocol]
@="protocol Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\myprotocol\DefaultIcon]
@="C:\\WINDOWS\\NOTEPAD.EXE"
[HKEY_CLASSES_ROOT\myprotocol\shell]
@=""
[HKEY_CLASSES_ROOT\myprotocol\shell\open]
@=""
[HKEY_CLASSES_ROOT\myprotocol\shell\open\command]
@="\"C:\\WINDOWS\\NOTEPAD.EXE\" "
3.编写一个HTML页面,在浏览器页面导航到此页面,点击hello链接
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div>
<a href="myprotocol://">
hello
</a>
</div>
</body>
</html>
参考文章:
https://blog.youkuaiyun.com/lwj_925/article/details/78333811