js调用exe文件 兼容所有浏览器

1. 先注册URL PROTOCOL, 在windows 下就是注册表:

========================================================

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\myprotocol]
@="myprotocol 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\" "

======================================================

保存内容为 reg文件,然后执行,就加入注册表,注册了这个名字为myprotocol 的协议.

2. 写测试页面



 
     
 
   
       


   


运行页面,点击链接,就能直接打开 notepad 。因为这里用的是写字板测试的,你可以在注册表中,改成其他任何你要的程序。


3.传参

Windows Registry Editor Version 5.00


[HKEY_CLASSES_ROOT\myprotocol]
@="myprotocol"
"URL Protocol"="D://CarTransfer.exe"


[HKEY_CLASSES_ROOT\myprotocol\DefaultIcon]
@="\"D:\\CarTransfer.exe" \"%1\""


[HKEY_CLASSES_ROOT\myprotocol\shell]
@=""


[HKEY_CLASSES_ROOT\myprotocol\shell\open]
@=""


[HKEY_CLASSES_ROOT\myprotocol\shell\open\command]
@="\"D:\\CarTransfer.exe\" \"%1\""



js部分

location.href="myprotocol://"+ sessionId +"&"+carsTransferId+"&"+carLicensePlate;



你可能感兴趣的:(js)