简体   繁体   English

WPF Webbrowser-在IE11上访问文档正文

[英]WPF Webbrowser - Access to Document Body on IE11

I'm developing a Desktop application which stores the GUI layer on html files as embedded resources. 我正在开发一个桌面应用程序,它将GUI层存储在html文件中作为嵌入式资源。 And I have a WPF Web Browser that manages the user interface lifecycle. 我有一个WPF Web浏览器,用于管理用户界面的生命周期。 I'm able to do all the job with no problems. 我能够毫无问题地完成所有工作。 But I've recently found out that when enabling the FEATURE_BROWSER_EMULATION to IE 11 (11000), the document body becomes inaccessible. 但是我最近发现,当对IE 11(11000)启用FEATURE_BROWSER_EMULATION时,文档正文变得不可访问。 Then, when using IE 10 (10000) everything works nicely. 然后,使用IE 10(10000)时一切正常。

The example below shows how to get the document body OffsetHeight: 下面的示例显示如何获取文档正文OffsetHeight:

dynamic document = (this.wbContent.Document as dynamic);
if ((document == null) || (document.body == null)) return 0;
return document.body.OffsetHeight;

The HTML is: HTML是:

<html>
    ...
    <body style="width: 170px; height: 240px">
        ...
    </body>
</html>

When using IE 11 it throws an exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException'. 使用IE 11时,它将引发类型为“ Microsoft.CSharp.RuntimeBinder.RuntimeBinderException”的异常。

When using IE 10 it returns 240. 使用IE 10时,它返回240。

Have you got any idea about how to access body on IE 11? 您是否知道如何在IE 11上访问正文?

As I did not get any answer about solving the problem, I had to trick in order to work around the bug. 由于未获得解决问题的任何答案,因此我不得不进行欺骗以解决该错误。 What is did is to put a simple JavaScript on the html file, so I call the method window.resizeTo(a, b). 所做的是在HTML文件上放置一个简单的JavaScript,因此我将方法称为window.resizeTo(a,b)。 After this event is called, the application get back working, but I actually don't know why. 调用此事件后,应用程序恢复工作,但我实际上不知道为什么。

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

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