Win Form App - Is it possible to catch a web address from a pop-up?
I have a Windows Form Application that has a tabControl with a webbrowser on a tab an on the other some textboxes. I need to access a website from the webbrowser. The problem is that on that website i have to click on a link that opens a pop-up. I was wondering if there is any way to avoid the popup and load the page in the webbrowser directly. If there's a way to catch the popup address, close the popup and load the page in the application's browser. The real problem would be catching the popup address if that's possible. Thank you very much.
Javeed M ShaikhPosted Nov 2, 2011, 9:47 AM
Please try the following ( I am looking at options on not to use this DLL):
1. Open your project.
2. take reference to this DLL: "C:\Windows\System32\shdocvw.dll"
3. try this code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SHDocVw;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
private SHDocVw.WebBrowser_V1 Web_V1; //Interface to expose ActiveX methods
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//Setup Web_V1 interface and register event handler
webBrowser1.GoBack();
Web_V1 = (SHDocVw.WebBrowser_V1)this.webBrowser1.ActiveXInstance;
Web_V1.NewWindow += new DWebBrowserEvents_NewWindowEventHandler(Web_V1_NewWindow);
webBrowser1.Navigate("http://www.popuptest.com/");
}
void Web_V1_NewWindow(string URL, int Flags, string TargetFrameName, ref object PostData, string Headers, ref bool Processed)
{
Processed = true; //Stop event from being processed
webBrowser1.Navigate(URL);
}
}
}
ion creangaPosted Nov 2, 2011, 11:28 AM
Javeed M ShaikhPosted Nov 2, 2011, 11:08 AM
ion creangaPosted Nov 2, 2011, 11:01 AM
The error looks like this. Do you know what could cause it?
ion creangaPosted Nov 2, 2011, 10:31 AM