简体   繁体   English

IHTMLDocument2 :: get_body在IE 11的CHtmlView中失败

[英]IHTMLDocument2::get_body fails in CHtmlView for IE 11

We've hit a simple, but critical, problem: IHTMLDocument2::get_body works in our embedded browser (CHtmlView) for IE7, but not IE11. 我们遇到了一个简单但关键的问题:IHTMLDocument2 :: get_body在IE7(而不是IE11)的嵌入式浏览器(CHtmlView)中工作。 We really want to start using the newer version, but this is a killer right now. 我们确实很想开始使用较新的版本,但这是目前的杀手er。

We use Visual Studio 2010. Native (unmanaged) C++. 我们使用Visual Studio2010。本机(非托管)C ++。 Problem occurs in both 32 and 64 bit builds. 在32位和64位版本中都会出现问题。 I don't know where this started failing (IE8? IE9? IE10?). 我不知道从哪里开始失败(IE8?IE9?IE10?)。 OnNavigateComplete2 has fired before we try to call this function. 在尝试调用此函数之前,已触发OnNavigateComplete2。

Here's our code, which has worked for us for a long time: 这是我们的代码,已经为我们工作了很长时间:

ComPtr<IHTMLTxtRange> CHighlightHTML::GetRange(ComPtr<IHTMLDocument2> document)
{
    ComPtr<IHTMLElement> elt;
    ComPtr<IHTMLBodyElement> body;

    if( SUCCEEDED(document->get_body(&elt.ReleaseGetValue())) )
        body = elt;

    if( body.IsValid() )
    {
        // Create a range from the entire body element.
        ComPtr<IHTMLTxtRange> range;
        CHECK_COM(body, createTextRange(&range.ReleaseGetValue()));
        return range;               
    }
}

But when we set the registry key: HKCU/Software/Microsoft/Internet Explorer/Main/FeatureControl/FEATURE_BROWSER_EMULATION 但是,当我们设置注册表项时:HKCU /软件/ Microsoft / Internet Explorer / Main / FeatureControl / FEATURE_BROWSER_EMULATION

to 11000 for our .exe, then elt == NULL (so fails the body.IsValid() test) 的.exe设置为11000,然后elt == NULL(因此body.IsValid()测试失败)

If we have not set the registry key, or set the key to 7000 (so browser control is IE7), then it works again. 如果我们尚未设置注册表项,或者未将注册表项设置为7000(因此浏览器控件为IE7),则它将再次起作用。

Help! 救命!

Robert Aldwinckle gave me the answer on the msdn forum. Robert Aldwinckle在msdn论坛上给了我答案。 I needed to set the registry value to 11001 instead of 11000: 我需要将注册表值设置为11001,而不是11000:

11001 (0x2AF9   Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the !DOCTYPE directive.
11000 (0x2AF8)  IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM