代码之家  ›  专栏  ›  技术社区  ›  Dmitry Streblechenko

在HTMLDocument解析器中禁用VML支持

  •  1
  • Dmitry Streblechenko  · 技术社区  · 8 年前

    我正在解析和处理由Word创建的现有HTML文件(这些文件无法重新创建)。嵌入图像的HTML文件包括支持vml的浏览器的条件格式,类似于以下内容:

         <!--[if gte vml 1]>
         <v:shape
         id="_x0000_i1042" type="#_x0000_t75" style='width:24pt;height:24pt'>
         <v:imagedata src="test_files/image002.png" o:title="Text-HighlightColor-icon_32x32"/>
        </v:shape>
        <![endif]-->
        <![if !vml]>
        <img width=32 height=32 src="test_files/image002.png" v:shapes="_x0000_i1042">
        <![endif]>
    

    IHTMLDocument2 对象由于IE支持VML,它解析出 <img> 只留下上面的标签 shape imagedata 标签。我宁愿忽略所有特定于vml的标记,只使用 < 标签

    IHTMLDocument2.desgnMode = "On" 以编程方式禁用脚本?

    1 回复  |  直到 8 年前
        1
  •  1
  •   Simon Mourier    8 年前

    单词生成的内容称为 "Conditional comments" . 更具体地说,我们这里有“下层隐藏条件注释”,其形式如下:

    <!--[if expression]> HTML <![endif]-->
    

    这个 expression "Version vectors" . 通常,这些向量指的是“IE”,用于处理 HTML compatiblity issues .

    但您可以使用自定义版本向量:

    网页的版本信息。要定义自定义版本向量, 此处显示。

    HKEY_LOCAL_MACHINE
       Software
          Microsoft
             Internet Explorer
                Version Vector
                   Contoso = 0.9
    

    上一个示例使用自定义版本向量表示 虚构的Contoso控件的预发布版本(0.9)为 安装在用户的计算机上。下一个示例显示了

    <!--[if lt Contoso 2]>
    <p>Your version of the Contoso control is out of date; Please update to the latest.</p>
    <![endif]-->
    

    由于VML本身是一个(嵌入式)插件,因此您可以使用 HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Version Vector\VML HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\Internet Explorer\Version Vector\VML . 显然,完全删除密钥解决了您的问题。

    推荐文章