1 回答

TA貢獻1827條經(jīng)驗 獲得超4個贊
簡短的故事 - 在查看 ITS (CHM) 文件內(nèi)部時使用完整路徑。根據(jù)我的測試,相對路徑規(guī)范(包括 CHM 中的主題規(guī)范)不起作用。它僅適用于 CHM 幫助文件本身。
幾年前的一系列安全修復已將 HTMLHelp 縮減為僅充當本地幫助。也許這個問題已經(jīng)得到了不同的解決。
我希望給您一個想法,但您必須根據(jù)您的需求進行調(diào)整(您提到使用IE11)。我沒有使用 Flash ActionScript 的經(jīng)驗,因為它也一直存在安全問題。所以,我不知道為什么 ActionScript 在這種情況下可以工作,而 JavaScript 不能。
HTML Help 1.x 不具備通過 http 提供壓縮幫助的功能。您可以指向用戶本地驅(qū)動器上的 .chm,也可以鏈接到 .chm 進行下載,但僅此而已。
查看 ITS (CHM) 文件內(nèi)部的功能僅是Microsoft Internet Explorer 所獨有的。只有 Internet Explorer(不是 Microsoft Edge 瀏覽器)可以加載本地路徑,例如:
ms-its:D:\_temp\CHM-example.chm::/garden/garden.htm
該前綴ms-its是早期的可插入?yún)f(xié)議,遵循萬維網(wǎng)聯(lián)盟 (W3C) 制定的舊標準。該ms-its協(xié)議適用于 Microsoft Internet Explorer 4.0 或更高版本,但并非所有瀏覽器都支持。
因此,我在同一個本地文件夾中有一個test.htm文件和一個CHM-example.chmD:\_working文件。請注意,window.showHelp在外部應(yīng)用程序(幫助查看器 hh.exe)中打開 HTML 幫助文件 (.chm)。
請務(wù)必使用 Internet Explorer 11(上下文菜單,使用 IE11 打開)進行測試。AFAIK -showHelp()不是 javascript(或 JScript)函數(shù) - 它是 Microsoft Internet Explorer DHTML 方法。
<!DOCTYPE html>
<html>
<head>
? ? <script type="text/javascript">
? ? ? ? ? ??
? ? ? ? function OpenHelpFile () {
? ? ? ? ? ? // open help file in help viewer - IE 11 only
? ? ? ? ? ? // --------------------------------------------------------
? ? ? ? ? ? // for optional use cases when CHM resides in another place
? ? ? ? ? ? // var DriveStr = "D:";
? ? ? ? ? ? // var SubFolderStr = "_working";
? ? ? ? ? ??
? ? ? ? ? ? var HelpFileName = "CHM-example.chm";
? ? ? ? ? ? var HelpFileStr = HelpFileName;
? ? ? ? ? ??
? ? ? ? ? ? // open help file topic in help viewer - IE 11 only
? ? ? ? ? ? // --------------------------------------------------------
? ? ? ? ? ? <!-- window.showHelp ("CHM-example.chm", null) -->
? ? ? ? ? ? alert ("attempted to launch the showHelp file. URL is: " + HelpFileStr);
? ? ? ? ? ? window.showHelp (HelpFileStr);
? ? ? ? }
? ? ? ? function OpenHelpTopic () {
? ? ? ? ? ? //? open help file topic in help viewer - IE 11 only
? ? ? ? ? ? // --------------------------------------------------------
? ? ? ? ? ? var DriveStr = "D:";
? ? ? ? ? ? var SubFolderStr = "_working";
? ? ? ? ? ? var HelpFileName = "CHM-example.chm";
? ? ? ? ? ? var HelpTopicStr = DriveStr + "\\" + SubFolderStr + "\\" + HelpFileName + "::" + "/garden/flowers.htm";? ?
? ? ? ? ? ??
? ? ? ? ? ? // open help file topic in help viewer - IE 11 only
? ? ? ? ? ? // --------------------------------------------------------
? ? ? ? ? ? <!-- window.showHelp ("D:\\_working\\CHM-example.chm::/garden/flowers.htm", null) -->
? ? ? ? ? ? alert ("attempted to launch the showHelp file. URL is: " + HelpTopicStr);
? ? ? ? ? ? window.showHelp (HelpTopicStr);
? ? ? ? }
? ? ? ? function OpenHelpTopicInNewTab () {
? ? ? ? ? ? // open help topic in new tab - only working inside IE11 using ms-its protocol
? ? ? ? ? ? // ---------------------------------------------------------------------------
? ? ? ? ? ? // "ms-its:D:\_working\CHM-example.chm::/garden/garden.htm"
? ? ? ??
? ? ? ? ? ? var ProtocolStr = "ms-its:";
? ? ? ? ? ? var DriveStr = "D:";
? ? ? ? ? ? var PathToFileStr = "\\_working\\CHM-example.chm";
? ? ? ? ? ? var HelpTopicStr = ProtocolStr + DriveStr + PathToFileStr + "::" + "/garden/garden.htm";
? ? ? ? ? ??
? ? ? ? ? ? alert ("attempted to launch the showHelp file. URL is: " + HelpTopicStr);
? ? ? ? ? ??
? ? ? ? ? ? // please note: window.open (!) ---------------------------------------------
? ? ? ? ? ? window.open (HelpTopicStr, null);
? ? ? ? }
? ? ? ??
? ? </script>
</head>
<body>
<p>Help Information www.help-info.de</p>
<hr />
<p>Open a help file</p>
<div>
? ? <button onclick="OpenHelpFile ();">Open a help file!</button>
</div>
<hr />
<p>Open a help topic</p>
<div>
? ? <button onclick="OpenHelpTopic ();">Open a help topic!</button>
</div>
<hr />
<p>Open a help topic in a new browser tab</p>
<div>
? ? <button onclick="OpenHelpTopicInNewTab ();">Open a help topic in a new browser tab!</button>
</div>
</body>
按鈕步驟(2 和 3)將生成下面的屏幕截圖(請注意第二個瀏覽器選項卡是第三個按鈕的結(jié)果)。
您可能需要CHM-example.chm
從我的 HTMLHelp (HH) 信息站點下載上述使用的文件
將此 CHM 文件保存到本地驅(qū)動器后的第一步:請檢查雙擊 CHM 文件后,內(nèi)容是否完整顯示在右側(cè)主題窗口中。
如果沒有,請注意 - 要打開此 CHM 文件,請右鍵單擊該文件,單擊“屬性”,然后選中“取消阻止”并單擊“確定”,如下面的屏幕截圖所示:
在同一目錄中根據(jù)上面的代碼創(chuàng)建后,test.htm
請確保使用 Internet Explorer 打開并允許阻止的內(nèi)容。
出于安全原因,瀏覽器窗口底部帶有按鈕的消息將在大約 10 秒后自動消失。
添加回答
舉報