分享

WebBrowser控件的window.close 问题

 昵称597197 2011-02-23
经过测试,终于找到了一种方法可以解决window.close的问题了
 1   private void wb_Container_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 2        {
 3            wb_Container.Document.Window.Unload += new HtmlElementEventHandler(Window_Unload);
 4        }

 5
 6        void Window_Unload(object sender, HtmlElementEventArgs e)
 7        {
 8            if (this.wb_Container.Document == null)
 9                this.Close();
10        }

原理:
1:代理window的unload事件。这个事件在页面卸载的时候触发。
2:在这个事件之后检查webbrowser的值。如果是window.close,那么属性为空。
可能这个方法还是不够好,但是现下可用了。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多