PC網頁js調用本地應用程序


最近要現實一個在PC網頁中實現點擊按鈕調用本地應用程序的功能

其實實現原理也非常簡單,

首先注冊一個本地注冊表文件,指向本地應用程序路徑

其次在網頁中用js指向這個注冊表文件,就可以實現網頁調用本地應用程序 

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;">打開QQ音樂</button>
<a href="myprotocol://D:\work\data\2018\08-11\11-16\myprotocol.reg" style="margin: 200px auto;">打開QQ音樂</a>
</body>
</html>

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM