1

There's a document I'm displaying in a web browser ActiveX control hosted in a C++ app. This document has a META tag that specifies incorrect charset, so the output is funny. I know the correct encoding and want to change it programmatically to fix that. But whatever I try, the encoding remains unchanged.

I alredy tried, in various combinations and flavors:

  • IHTMLDocument2::put_Charset (after the document finished loading);
  • changing the "charset" property of the "META" tag (using IHTMLMetaElement);
  • deleting the "META" tag altogether (by setting its "outerHTML" to empty string);
  • refreshing the control.

The control demonstrates remarkable persistence in preserving the incorrect encoding. What are my other options? I can't manipulate the source of the document being loaded.

4

3 回答 3

1

尝试把designMode属性"On"

于 2012-10-08T01:09:35.240 回答
0

以下是最终奏效的方法:

在“NavigateComplete2”浏览器事件的处理程序中,

  • 使用 charset 属性修改字符集,
  • 然后通过将其 outerHTML 设置为空字符串来丢弃 META 标签,
  • 然后刷新控件。

修改这些动作的顺序,或者省略一个步骤,都会导致整个操作无效。MSHTML 很挑剔。

于 2012-01-28T21:13:01.067 回答
0

据此,如果IWebBrowser->Refresh()您在调用后调用它应该可以工作IHTMLDocument2->put_charset()

于 2012-01-27T21:26:01.807 回答