js调用本地exe文件

JavaScript015

js调用本地exe文件,第1张

通过注册表进行打开本地的exe的运行文件。

打开记事本,随便命名,保存下面的内容

需要修改的地方:

保存,修改后缀名为reg;双击运行自动生成ChiticData的协议,在Html中写上这个协议即可打开本地运行程序

JS打开选择本地文件的对话框:

方法一:

在定义的form中添加以下javascript代码:

{

              anchor : '95%',

              xtype: 'fileuploadfield',

              id: 'form-file',

              emptyText: '请选择',

              fieldLabel: '上传附件',

              name: 'meetingAffix',

              buttonText: 'Browse'

    }

单击Browse按钮后可以打开对话框,选中文件后,所选文件路径会出现在上传附件后面的文本框中。

方法二:

在定义的form中添加以下javascript代码:

{

      columnWidth :1,

      layout :'form',

      bodyStyle :'padding:10px',

      defaultType :'textfield',

      labelWidth :120,

      width :1000,

      buttonAlign :'center',

      items : [ {

       fieldLabel :'请选择要上传的文件',

       name :'fileName',

       id :'fileId',

       anchor :'95%',

      allowBlank :false,

       inputType :'file'

      } ]

}

方法三:

给按钮定义以下javascript函数:

var inputObj=document.createElement('input')

         inputObj.setAttribute('id','_ef')

         inputObj.setAttribute('type','file')

         inputObj.setAttribute("style",'visibility:hidden')

         document.body.appendChild(inputObj)

         inputObj.click()

         inputObj.value 

单击已经添加函数的按钮会弹出选择本地文件的对话框。

用这个方法:

var WordApp=new ActiveXObject("Word.Application")

//注:IE的ActiveX安全性能放开才行

WordApp.Application.visible=false

var Doc=WordApp.documents.open(path)

//对word 的操作见office的MSDN

WordApp.quit()