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

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

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

      1. IE 8 的 InternetExplorer COM 对象忽略了活动选项卡

        Active tab ignored by InternetExplorer COM object for IE 8(IE 8 的 InternetExplorer COM 对象忽略了活动选项卡)

        • <legend id='trl4B'><style id='trl4B'><dir id='trl4B'><q id='trl4B'></q></dir></style></legend>

        • <tfoot id='trl4B'></tfoot>
        • <small id='trl4B'></small><noframes id='trl4B'>

            <bdo id='trl4B'></bdo><ul id='trl4B'></ul>

                  <tbody id='trl4B'></tbody>
                <i id='trl4B'><tr id='trl4B'><dt id='trl4B'><q id='trl4B'><span id='trl4B'><b id='trl4B'><form id='trl4B'><ins id='trl4B'></ins><ul id='trl4B'></ul><sub id='trl4B'></sub></form><legend id='trl4B'></legend><bdo id='trl4B'><pre id='trl4B'><center id='trl4B'></center></pre></bdo></b><th id='trl4B'></th></span></q></dt></tr></i><div id='trl4B'><tfoot id='trl4B'></tfoot><dl id='trl4B'><fieldset id='trl4B'></fieldset></dl></div>
                  本文介绍了IE 8 的 InternetExplorer COM 对象忽略了活动选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是在 .net 3.5 winform 上运行的网络单点登录代码.只要 ie8 只打开一个选项卡,代码对于 ie6 或 ie8 运行良好.问题是,如果用户打开一个新选项卡(选项卡 2,3 等)并导航到网站(组织内部的 Web 表单),将执行以下代码,但即 COM 自动化对象将返回 HTMLDocument对于第一个选项卡(选项卡 1),即使选项卡 2 是活动选项卡.我在任何地方的 InternetExplorer 或 HTMLDocument 类中都找不到任何 IE 选项卡引用.实际上,IE COM 自动化文档中几乎没有 IE 标签相关的文档.

                  This is web single sign on code that runs on a .net 3.5 winform. The code runs fine for ie6 or ie8 as long as ie8 only has one tab open. The problem is that if the user opens a new tab (tab 2,3,etc.) and navigates to a web site (web form internal in the organization) the below code will be executed but the ie COM automation object will return the HTMLDocument for the first tab (Tab 1) even though tab 2 is the active tab. I can't find any IE tab references in the InternetExplorer or HTMLDocument classes anywhere. Actually, there's very little IE tab related documentation anywherer in the IE COM automation docs.

                  AutoResetEvent ie2_NavigateCompleteAutoReset;
                  
                      /// <summary>
                      /// Given the handle of an Internet Explorer instance, this method performs single sign on to
                      /// several known web login forms.
                      /// </summary>
                      /// <param name="iEFramHandle"></param>
                      private void WebFormSignOn(int iEFramHandle)
                      {
                          foreach (SHDocVw.InternetExplorer ie2 in new SHDocVw.ShellWindows())
                          {
                              if (ie2.HWND == iEFramHandle)
                              {
                                  while (true)
                                  {
                                      Thread.Sleep(100);
                                      if (ie2.ReadyState == SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
                                      {
                                          try
                                          {
                                              mshtml.HTMLDocument doc = (mshtml.HTMLDocument)ie2.Document;
                                              ie2.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(ie2_NavigateComplete2);
                                              ie2_NavigateCompleteAutoReset = new AutoResetEvent(false);
                  
                                              /*Find the username element and enter the user's username*/
                                              mshtml.HTMLInputElement userID = (mshtml.HTMLInputElement)doc.all.item("username", 0);
                                              userID.value = Globals.Username;
                  
                                              /*Find the password element and enter the user's password*/
                                              mshtml.HTMLInputElement pwd = (mshtml.HTMLInputElement)doc.all.item("password", 0);
                                              pwd.value = Globals.GetAppName();
                  
                                              /*Find the submit element/button and click it*/
                                              mshtml.HTMLInputElement btnsubmit = (mshtml.HTMLInputElement)doc.all.item("submit", 0);
                                              btnsubmit.click();
                  
                                              /*Wait up to 5 seconds for the form submit to complete.
                                               This is to prevent this method from being called multiple times
                                               while waiting for the form submit and subsequent navigation from completing.*/
                                              ie2_NavigateCompleteAutoReset.WaitOne(5000);
                                              return;
                                          }
                                          catch (Exception err)
                                          {
                                              Logger.Log(err.ToString(), Logger.StatusFlag.Error, this.ToString(), "WebFormSignOn");
                                              return;
                                          }
                                          finally
                                          {
                                              /*Remove the event handler*/
                                              ie2.NavigateComplete2 -= ie2_NavigateComplete2;
                  
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  
                      void ie2_NavigateComplete2(object pDisp, ref object URL)
                      {
                          ie2_NavigateCompleteAutoReset.Set();
                      }
                  

                  推荐答案

                  原来IE 8中的每个tab都有自己的进程和句柄.在原始代码中,我总是从第一个 IEFrame 获取句柄.我修改了代码(如下),现在它可以工作了.变化在于,代码不仅查找第一个 IEFrame 句柄,还查找与触发调用 WebFormsSignOut 的方法的 url 匹配的 LocationURL.

                  It turns out that each tab in IE 8 has it's own process and handle. In the original code i was always getting the handle from the first IEFrame. I modified the code (below) and now it works. The change is that instead of looking for just the first IEFrame handle, the code also looks for a LocationURL that matches the url that triggerd the method that calls WebFormsSignOut.

                  private void WebFormSignOn(int iEFramHandle,string addressBarText)
                  {
                      var shellWindows = new SHDocVw.ShellWindows();
                      foreach (SHDocVw.InternetExplorer ie2 in shellWindows)
                      {
                          if (ie2.LocationURL==addressBarText)
                          { //rest of the code (see orignal post)
                  

                  这篇关于IE 8 的 InternetExplorer COM 对象忽略了活动选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Accessing attribute info from DTE(从 DTE 访问属性信息)
                  c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  C# Attributes and their uses(C# 属性及其用途)
                  C# - Getting all enums value by attribute(C# - 按属性获取所有枚举值)
                  <tfoot id='4IS2n'></tfoot>
                    • <legend id='4IS2n'><style id='4IS2n'><dir id='4IS2n'><q id='4IS2n'></q></dir></style></legend>

                          <small id='4IS2n'></small><noframes id='4IS2n'>

                            <bdo id='4IS2n'></bdo><ul id='4IS2n'></ul>
                              <tbody id='4IS2n'></tbody>

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