1. <legend id='oP2sk'><style id='oP2sk'><dir id='oP2sk'><q id='oP2sk'></q></dir></style></legend>

        <bdo id='oP2sk'></bdo><ul id='oP2sk'></ul>
      <tfoot id='oP2sk'></tfoot>
    2. <small id='oP2sk'></small><noframes id='oP2sk'>

    3. <i id='oP2sk'><tr id='oP2sk'><dt id='oP2sk'><q id='oP2sk'><span id='oP2sk'><b id='oP2sk'><form id='oP2sk'><ins id='oP2sk'></ins><ul id='oP2sk'></ul><sub id='oP2sk'></sub></form><legend id='oP2sk'></legend><bdo id='oP2sk'><pre id='oP2sk'><center id='oP2sk'></center></pre></bdo></b><th id='oP2sk'></th></span></q></dt></tr></i><div id='oP2sk'><tfoot id='oP2sk'></tfoot><dl id='oP2sk'><fieldset id='oP2sk'></fieldset></dl></div>

      1. 怎样把WebBrowser控件放到IE9成标准?

        时间:2023-09-07
            <bdo id='q1Rjd'></bdo><ul id='q1Rjd'></ul>
            • <i id='q1Rjd'><tr id='q1Rjd'><dt id='q1Rjd'><q id='q1Rjd'><span id='q1Rjd'><b id='q1Rjd'><form id='q1Rjd'><ins id='q1Rjd'></ins><ul id='q1Rjd'></ul><sub id='q1Rjd'></sub></form><legend id='q1Rjd'></legend><bdo id='q1Rjd'><pre id='q1Rjd'><center id='q1Rjd'></center></pre></bdo></b><th id='q1Rjd'></th></span></q></dt></tr></i><div id='q1Rjd'><tfoot id='q1Rjd'></tfoot><dl id='q1Rjd'><fieldset id='q1Rjd'></fieldset></dl></div>

                <small id='q1Rjd'></small><noframes id='q1Rjd'>

                  <tbody id='q1Rjd'></tbody>
                <tfoot id='q1Rjd'></tfoot>
                <legend id='q1Rjd'><style id='q1Rjd'><dir id='q1Rjd'><q id='q1Rjd'></q></dir></style></legend>

                • 本文介绍了怎样把WebBrowser控件放到IE9成标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用自动化(即 COM 自动化)在 Internet Explorer (9) 中显示一些 HTML:

                  ie = CoInternetExplorer.Create;ie.Navigate2(about:blank");webDocument = ie.Document;webDocument.Write(szSourceHTML);webDocument.Close();ie.Visible = True;

                  Internet Explorer 出现,显示我的 html,开头为:

                  <!DOCTYPE html><HTML><头>...

                  <块引用>

                  注意: html5 标准模式选择加入文档类型 html

                  除非文档不是ie9标准模式;它处于 ie8 标准模式:


                  如果我先将 html 保存到我的电脑:

                  然后查看那个 html文档,IE进入标准模式:

                  我的问题是如何更新我的 SpawnIEWithSource(String html) 函数以使浏览器进入标准模式?

                  void SpawnIEWithSource(String html){变体 ie = CoInternetExplorer.Create();ie.Navigate2(about:blank");webDocument = ie.Document;webDocument.Write(html);webDocument.Close();ie.Visible = true;}


                  一个更冗长、更难理解或可读性更强的代码示例,这无助于进一步的问题可能是:

                  IWebBrowser2 即;CoCreateInstance(CLASS_InternetExplorer, null, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_WebBrowser2, ie);即.AddRef();ie.Navigate2(about:blank");IHtmlDocument 文档;dispDoc = ie.Document;dispDoc.AddRef();dispDoc.QueryInterface(IHTMLDocument2, doc);dispDoc.Release()doc.Write(html);doc.Close();doc.Release();ie.Visible = true;即.Release();


                  更新

                  评论者在 ieblog 条目中询问 使用浏览器模式与 Doc 测试网站模式:

                  <块引用>

                  当 HTML 内容在嵌入的 web 控件中时,我们能否描述如何确定文档模式?似乎是选择了不同的文档模式 - 可能是出于兼容性原因?

                  MarkSil [MSFT] 回应:

                  <块引用>

                  @Thomas:感谢您提出这个问题.WebBrowser Control 以与 IE 相同的方式确定文档模式,因为它包含相同的 Web 平台(例如,IE 和 WebBrowser Control 主机之间有一个共享的 mshtml.dll).WebBrowser 控件默认为兼容性视图浏览器模式,这意味着默认的文档模式是 IE7.这是一篇博客文章,其中包含更多详细信息:blogs.msdn.com/.../more-ie8-extensibility-improvements.aspx.

                  Thomas 回应:

                  <块引用>

                  @MarcSil(回复:WebBrowser 控件)

                  使用注册表项为 WebControl 选择文档模式的问题在于它适用于整个应用程序.我为 Google SketchUp 编写插件,您可以在其中使用 WebDialog 窗口来创建 UI——它只是一个窗口中的 WebBrowser 控件.但这会导致问题,因为我想为我的 WebBrowser 控件实例强制使用文档模式,而不是对整个 SU 的所有 WebBrowser 控件.

                  所以,我的问题是:如何控制 WebBrowser 控件的每个实例的文档模式?

                  解决方案

                  你试过在你的html中设置

                  表示最新版本

                  i am using automation (i.e. COM automation) to display some HTML in Internet Explorer (9):

                  ie = CoInternetExplorer.Create;
                  ie.Navigate2("about:blank");
                  webDocument = ie.Document;
                  webDocument.Write(szSourceHTML);
                  webDocument.Close();
                  ie.Visible = True;
                  

                  Internet Explorer appears, showing my html, which starts off as:

                  <!DOCTYPE html>
                  <HTML>
                  <HEAD>
                     ...
                  

                  Note: the html5 standards-mode opt-in doctype html

                  Except that the document is not in ie9 standards mode; it's in ie8 standards mode:


                  If i save the html to my computer first:

                  and then view that html document, IE is put into standards mode:

                  My question is how update my SpawnIEWithSource(String html) function to throw the browser into standards mode?

                  void SpawnIEWithSource(String html)
                  {
                     Variant ie = CoInternetExplorer.Create();
                     ie.Navigate2("about:blank");
                     webDocument = ie.Document;
                     webDocument.Write(html);
                     webDocument.Close();
                     ie.Visible = true;
                  }
                  


                  Edit: A more verbose, less understandable or readable code sample, that doesn't help further the question might be:

                  IWebBrowser2 ie;
                  CoCreateInstance(CLASS_InternetExplorer, null, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_WebBrowser2, ie);
                  ie.AddRef();
                  ie.Navigate2("about:blank");
                  
                  IHtmlDocument doc;
                  dispDoc = ie.Document;
                  dispDoc.AddRef();
                  dispDoc.QueryInterface(IHTMLDocument2, doc);
                  dispDoc.Release()
                  doc.Write(html); 
                  doc.Close();
                  doc.Release();
                  ie.Visible = true;
                  ie.Release();
                  


                  Update

                  Commenter asked on the ieblog entry Testing sites with Browser Mode vs. Doc Mode:

                  Can we get a description of how the document mode is determined when the HTML content is within an embedded webcontrol? Seems to be that the document mode is choosen differently - maybe for compatibility reasons?

                  MarkSil [MSFT] responded:

                  @Thomas: Thanks for raising that question. The WebBrowser Control determines the doc mode the same way that IE does because it contains the same web platform (e.g. there is one shared mshtml.dll across IE and WebBrowser Control hosts). The WebBrowser Control does default to the Compatibility View browser mode, which means that the default doc mode is IE7. Here is a blog post with more detail on this: blogs.msdn.com/.../more-ie8-extensibility-improvements.aspx.

                  To which Thomas responded:

                  @MarcSil (re: WebBrowser Control)

                  The problem with using registry entries to select document mode for WebControl is that it applies to the application as a whole. I write plugins for Google SketchUp where you have WebDialog windows to create UIs - it's just a WebBrowser control in a window. But that leads to problems as I want to force a document mode for my instance of the WebBrowser control, not for all of SU's WebBrowser controls as a whole.

                  So, my question is: how do you control the document mode per instance for a WebBrowser control?

                  解决方案

                  Have you tried setting in your html the

                  <meta http-equiv="X-UA-Compatible" content="IE=9" />
                  

                  or

                  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
                  

                  which means latest version

                  这篇关于怎样把WebBrowser控件放到IE9成标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                      <legend id='SzXE9'><style id='SzXE9'><dir id='SzXE9'><q id='SzXE9'></q></dir></style></legend>
                      • <i id='SzXE9'><tr id='SzXE9'><dt id='SzXE9'><q id='SzXE9'><span id='SzXE9'><b id='SzXE9'><form id='SzXE9'><ins id='SzXE9'></ins><ul id='SzXE9'></ul><sub id='SzXE9'></sub></form><legend id='SzXE9'></legend><bdo id='SzXE9'><pre id='SzXE9'><center id='SzXE9'></center></pre></bdo></b><th id='SzXE9'></th></span></q></dt></tr></i><div id='SzXE9'><tfoot id='SzXE9'></tfoot><dl id='SzXE9'><fieldset id='SzXE9'></fieldset></dl></div>
                          <bdo id='SzXE9'></bdo><ul id='SzXE9'></ul>
                            <tbody id='SzXE9'></tbody>

                        • <small id='SzXE9'></small><noframes id='SzXE9'>

                          • <tfoot id='SzXE9'></tfoot>