How does Js call local applications and Js call applications?
Generally, the browser cannot directly interact with other programs on the local machine. In IE, we can use ActiveX objects. However, this method only applies to IE browsers. Another common method is the URL protocol. We register a URL protocol to a program for processing, such as tencent: // This protocol is registered with the QQ program for processing. When the browser needs to access this Protocol, it is transferred to the QQ program for processing. This URL protocol can be used across platforms. For example, you need to add a registry key on Windows.
First, let's look at how js calls the qq client.
Window. Open ("tencent: // message /? Uin = 346915968 ")
Window. open. Don't talk about Tencent. bat t. The above dialog box can be opened directly for the qq account. We can see how the online customer service function on the Web page is implemented.
What should I do if I want to log on to qq without opening a dialog box? Very simple:
Window. Open ("tencent: // message /? Uin = qq ") However, browsers generally prohibit the calling of applications, which is similar to that of hackers,
After you select allow,
When the application is started, the qq client is started.
Why do I need to talk about this? The boss gave me another requirement. I wanted to call the qq client and use a button on the demo page to call various programs of the ticket sales system...
Let's talk about nothing. Let's first look at what a custom protocol is.
Pluggable Protocol, also called URL Protocol, is sometimes called a Shell command. common protocols include http, ftp, and mailto. These are the built-in protocols for windows installation.
Then implement a simple custom protocol.
1. Run window and enter regedit to open the registry. Create a table named by yourself under HKEY_CLASSES_ROOT.
Add values in the following format:
Jsopen QQ music .exe
Start the application
End.