简体   繁体   English

获取从ac#应用程序创建的IE popupwidow的状态

[英]Get the status of IE popupwidow created from a c# application

I have created an internet explorer toolbar using C#. 我已经使用C#创建了Internet Explorer工具栏。 On clicking on that toolbar button , I want to open internet explorer popup window. 在单击该工具栏按钮时,我想打开Internet Explorer弹出窗口。 I have used web browser control with in the form and its invoke script method. 我已经在表单及其调用脚本方法中使用过Web浏览器控件。 With in the java script I have used window.open method to open the new window popup. 在Java脚本中,我使用window.open方法来打开新的窗口弹出窗口。 I need to identify whether the popup is closed or not with in the form?. 我需要确定窗体中是否关闭了弹出窗口?

Since this is from within a Windows application, you might find it easier to create a separate form with its own (visible) WebBrowser control, with its Url property set to whatever address you were using in the javascript window.open method. 由于这是从Windows应用程序中获取的,因此您可能会发现,使用其自己的(可见)WebBrowser控件创建单独的表单会更容易,其Url属性设置为您在javascript window.open方法中使用的任何地址。

Here is a simple example of how to do this from a button's click event: 这是一个如何通过按钮的click事件执行此操作的简单示例:

private void button1_Click(object sender, EventArgs e)
{
    Form f = new Form();
    WebBrowser wb = new WebBrowser();
    wb.Url = new Uri(@"http://www.stackoverflow.com");
    wb.Dock = DockStyle.Fill;
    f.Controls.Add(wb);
    f.FormClosed += f_FormClosed;
    f.Show();
}

void f_FormClosed(object sender, FormClosedEventArgs e)
{
    MessageBox.Show("popup has closed");
}

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

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