【问题标题】:Trying to create an ActiveX Template Coach (TCard) object using Javascript Onclick event尝试使用 Javascript Onclick 事件创建 ActiveX 模板指导 (TCard) 对象
【发布时间】:2023-06-09 18:37:01
【问题描述】:

我目前正在尝试创建一个 CHM 帮助文件,用户可以在其中输入值,然后生成一个按钮以将 lPARAM 发送到 WM_TCARD。

目前,我已经在 IE 11、10、9 和 8 中进行了测试,根据 DOM Explorer 正在使用正确的参数创建对象,但它没有正确显示并且没有显示为按钮。

<body>
<button onclick="create_object();">Try it</button>
<input type="text" id="layout_enter" />
<button id=click_button99 onclick="click_new_object();">click</button>
<script>

function create_object() {

    var new_obj = document.createElement("OBJECT");
    new_obj.setAttribute("classid", "clsid:41B23C28-488E-4E5C-ACE2-BB0BBABE99E8");
    new_obj.setAttribute("codebase", "HHCTRL.ocx#Version=4,72,8252,0");
    new_obj.setAttribute("type", "application/x-oleobject");
    new_obj.setAttribute("id", "object99");
    document.body.appendChild(new_obj);

    var layout_entered = "10," + 
    document.getElementById('layout_enter').value

    var z = document.createElement("PARAM");
    z.setAttribute("name", "Button");
    z.setAttribute("value", "PP Sonic");
    document.getElementById("object99").appendChild(z);

    var y = document.createElement("PARAM");
    y.setAttribute("name", "Command");
    y.setAttribute("value", "TCard");
    document.getElementById("object99").appendChild(y);

    var x = document.createElement("PARAM");
    x.setAttribute("name", "Image");
    x.setAttribute("value", " ");
    document.getElementById("object99").appendChild(x);

    var w = document.createElement("PARAM");
    w.setAttribute("name", "Item1");
    w.setAttribute("value", layout_entered);
    document.getElementById("object99").appendChild(w);

    var v = document.createElement("PARAM");
    v.setAttribute("name", "UseButton");
    v.setAttribute("value", "TRUE");
    document.getElementById("object99").appendChild(v);

    var u = document.createElement("PARAM");
    u.setAttribute("name", "UseIcon");
    u.setAttribute("value", "TRUE");
    document.getElementById("object99").appendChild(u);
}

function click_new_object() {
    document.getElementById("object99").click();
}
</script>
</body>

任何帮助/建议将不胜感激。 我已经查看了 ActiveX 的 Internet 选项中的安全选项,但没有解决任何问题。如果我已经在代码中存在对象,那么它就会出现。让我觉得这不是对象的问题,而是创作的问题。

请注意:我不能使用 JQuery。

谢谢。

【问题讨论】:

    标签: javascript html object chm createelement


    【解决方案1】:

    据我所知,这已被安全更新破坏 - 按钮也被破坏。

    在 2004-2005 年期间,Windows 不断受到攻击。为了消除许多安全漏洞,MS 决定将 HTML 帮助的功能减少到仅支持本地帮助的功能。

    请务必注意,虽然 Workshop 帮助记录了以下远程功能,但它们实际上不再适用于 Windows XP 及更高版本。

    • HTML 帮助 ActiveX 控件 HH 查看器的主要帮助代码库(可执行文件)存储在 hhctrl.ocx 中。所以这是一个带有一些 ActiveX 功能的 DLL。在安全更新之前,您可以使用此控件将 TOC 和索引嵌入网页。
    • HTML 帮助 Java 小程序 这使用 Sun Java 作为将导航(TOC/索引)嵌入网页的替代方法。它从未由 Microsoft 维护,并且已陷入无法使用的状态(甚至在严重的安全更新之前)。所以请忽略此功能。

    多年前我尝试过使用快捷方式链接。作为丢失按钮的替代品? - 我确定!请注意,这仅适用于压缩的 CHM 文件。

    <html>
    <head>
    <title>Using CHM shortcut links</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta name="keywords" content="Shortcut, Link" />
    <meta name="MS-HKWD" content="Shortcut" />
    <meta name="MS-HKWD" content="Link" />
    <link href="../design.css" rel="stylesheet" type="text/css" />
    
    <OBJECT id=MyUniqueID type="application/x-oleobject"
    classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
      <PARAM name="Command" value="ShortCut">
      <PARAM name="Item1" value=",http://www.help-info.de/index.htm,">
      <PARAM name="Item2" value=",,">
      <!-- second item parameter seems to be required when downloaded from web with "Open/Save Dialog" -->
    </OBJECT>
    
    </head>
    
    <body>
    
    <h1>Using CHM shortcut links</h1>
    <p>This is a simple example how to use shortcut links from a CHM file and jump 
      to a URL with the users default browser.</p>
    <p>Example:</p>
    <p><a href="javascript:MyUniqueID.Click()">Click me to go to www-help-info.de</a></p>
    
    </body>
    </html>
    

    【讨论】:

      最近更新 更多