从hta打开.chm

时间:2015-01-30 19:46:45

标签: javascript vbscript hta chm

我有一个HTA,我已经制作了.chm帮助文件。我想要一个JavaScript或VBScript函数从HTA打开一个.chm文件,以便能够创建一个这样的帮助按钮:

<button onclick="//I don't know what to put here">Help</button>

我该怎么做?

1 个答案:

答案 0 :(得分:1)

在使用HTA的vbscript中,我们可以这样做:

<html>
<Title>How to open VBSCRIP5.CHM</Title>
<head>
<HTA:APPLICATION
ICON="cmd.exe"
APPLICATIONNAME = "How to open VBSCRIP5.CHM"
BORDER="dialog"
BORDERSTYLE="complex"
>
<style>
body{
background-color: DarkOrange;
}
</style>
</head>
<script type="text/Vbscript">
Sub OpenCHMFile()
Dim CHMFile
CHMFile = "C:\Program Files\Microsoft Office\Office12\1036\VBSCRIP5.CHM"
Call Launch(CHMFile)
End Sub
'********************************************
Sub Launch(MyProgram)
Dim ws,Result
Set ws = CreateObject("wscript.Shell")
Result = ws.run(DblQuote(MyProgram),1,False)
End Sub
'********************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'********************************************
</script>
<body text="white">
<center>
<input type="button" onClick="OpenCHMFile()" value="Open the help file">
</center>
</body>
</html>