最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過JavaScript打開CHM幫助文件到特定頁面

通過JavaScript打開CHM幫助文件到特定頁面

天涯盡頭無女友 2023-11-11 21:18:51
這里有很多關(guān)于這個主題的帖子,但沒有一個是從網(wǎng)頁啟動 CHM 幫助文件的解決方案。背景:該項目不在互聯(lián)網(wǎng)上,它是一個在 IE11 中運行的醫(yī)療設(shè)備上本地運行的網(wǎng)站。它之前被編碼為Flash ActionScript Web應(yīng)用程序,并成功使用了ActionScript的ExternalInterface.call(“callJavascript”,variableStr); 打開 CHM 文件。不幸的是,該項目需要移植到 HTML5,而我還沒有找到有效的 JavaScript 解決方案。CHM 文件及其中每個頁面的路徑取自 JSON 文件,并且根據(jù)需要訪問 CHM 中的哪個頁面,連接鏈接。chm/myHelp.chm::cat2page1.html就是一個示例 。因此,使用 ActionScript,當用戶單擊按鈕時,該函數(shù)會創(chuàng)建完整的字符串,傳遞給包含 HTML 頁面中名為“callJavascript”的 JavaScript 函數(shù),該函數(shù)又將 CHM 文件打開到正確的頁面:private function launchURL(e:MouseEvent) {        if (_helpLibIndex != "" && _myHelpLink != "") {            // ex: JavaScript:   callJavascript('chm/GloCyte.chm::cat2page1.html')            var variableStr:String = _helpLibIndex + "::" + _myHelpPageLink;            ExternalInterface.call("callJavascript", variableStr );        }    }以及托管 Flash swf 的 HTML 頁面上的 JavaScript:<script type="text/javascript">        function callJavascript(str) {            //window.alert(str);            window.showHelp(str);        }    </script>應(yīng)該很容易轉(zhuǎn)換為直接 JS - 對吧?不幸的是我有很多問題。在直接 HTML5 頁面中調(diào)用類似的函數(shù)時,在將完整的 CHM 路徑和頁面連接在一起并將其傳遞給啟動函數(shù)時,我收到 404 錯誤“找不到項目”。如果我忽略該頁面并僅使用 CHM 文件的路徑,瀏覽器會提示“打開或保存”該文件。當我選擇“打開”時,CHM 文件在 Microsoft HTML 幫助控件版本 10.0 中啟動到堆棧中的第一頁,但僅顯示頁面的導航面板,并且正文區(qū)域為空白/空。從以這種方式打開的導航面板中手動選擇頁面將不會在正文區(qū)域中顯示其內(nèi)容。但是,如果我從桌面手動打開 CHM 文件,它會顯示正文區(qū)域中的所有頁面,但從網(wǎng)頁啟動它時仍然失敗。這是我在新的 HTML5 頁面中的 JS 代碼。之前從導入的 JSON 文件中檢索 _helpLibIndex 和 _myHelpLink:function launchURL() {if (_helpLibIndex != "" && _myHelpLink != "") {   // appending myHelpLink gives 404 error.   // leaving it off kinda launches the CHM, but no content is viewable in the body area    // example string = 'chm/myHelp.chm::cat2page1.html'   var variableStr = _helpLibIndex + "::" + _myHelpLink;   window.showHelp(variableStr);   console.log("attempted to launch the showHelp file. URL is: " + variableStr);}我不太明白在這種情況下 ActionScript 工作與 JavaScript 不工作之間的區(qū)別,因為這兩種情況下的最終調(diào)用都是來自托管網(wǎng)頁的 JS。非常感謝任何幫助!
查看完整描述

1 回答

?
GCT1015

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

https://img1.sycdn.imooc.com/654f7f610001615a06510144.jpg

該前綴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é)果)。

https://img1.sycdn.imooc.com/654f7f7100019adf06520377.jpg

您可能需要CHM-example.chm從我的 HTMLHelp (HH) 信息站點下載上述使用的文件

將此 CHM 文件保存到本地驅(qū)動器后的第一步:請檢查雙擊 CHM 文件后,內(nèi)容是否完整顯示在右側(cè)主題窗口中。

如果沒有,請注意 - 要打開此 CHM 文件,請右鍵單擊該文件,單擊“屬性”,然后選中“取消阻止”并單擊“確定”,如下面的屏幕截圖所示:

https://img1.sycdn.imooc.com/654f7f7f00010ecf03550503.jpg

在同一目錄中根據(jù)上面的代碼創(chuàng)建后,test.htm請確保使用 Internet Explorer 打開允許阻止的內(nèi)容。

出于安全原因,瀏覽器窗口底部帶有按鈕的消息將在大約 10 秒后自動消失。

https://img1.sycdn.imooc.com/654f7f8c0001212a06390434.jpg

查看完整回答
反對 回復 2023-11-11
  • 1 回答
  • 0 關(guān)注
  • 436 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號