JS open the local application software

We have encountered can jump directly link to open QQ, but also encountered a direct office started to open the document.

Specifically how to do it?

Add a registry key

First, we need to add application software in the registry startup address, operating as follows

In HKEY_CLASSES_ROOT, New JiraUserQuestion its child nodes:

Then, in JiraUserQuestion, add the URL Protocol = "C: \ Program Files (x86) \ JiraUserQuestion \ JiraUserQuestion.exe".

- is defined herein Protocol, follow by detection protocol of the protocol, the application to access the local path

In the node below, command entry added default. By passing parameters, start the application

Js add access applications link

Add front-end demo:

 1 <!DOCTYPE html>
 2 <html>
 3 <head lang="en">
 4     <meta charset="UTF-8">
 5     <title>Custom Protocol Demo</title>
 6 </head>
 7 <body>
 8     <h1>Click:</h1>
 9     <a href="JiraUserQuestion://Open">Open JiraUserQuestion</a>
10     <script src="protocolcheck.js"></script>
11 </body>
12 </html>

protocolcheck.js file that protocol agreement js, from the Internet to download directly.

After downloading, place the file in html file with a convenient reference.

Click on the link, the effect is as follows:

Detect whether there is a local application

Protocolcheck.js above documents, the packaged load and logic determination url.

If the application exists, open the application; otherwise there is a corresponding correction may choose the transaction.

. 1      <Script>
 2          // test whether there is a local application 
. 3          the let protocalUrl = `JiraUserQuestion: // open` 
. 4          protocolCheck (protocalUrl, () => {
 . 5              Alert ( 'detected, the client is not installed' )
 6          }, ( ) => {
 . 7              Alert ( 'detected: the client has been installed' )
 . 8          })
 . 9      </ Script>

 If you want more details, you can download my Demo View

 

Reference list:

StackOverFlow Solution:  https://stackoverflow.com/questions/27489665/approaches-of-detection-of-custom-protocol-in-chrome-and-safari-browsers 

Custom Protocol Detection in Browser源码:   https://github.com/ismailhabib/custom-protocol-detection

Native-App-Protocal-Detection Source Address: https://github.com/evanxuhe/Native-App-Protocal-Detection

js detect whether the client installation: HTPS: //www.cnblogs.com/damonFeng/p/12095558.html

 

Guess you like

Origin www.cnblogs.com/kybs0/p/12508305.html
Recommended