Web Browser Help - getting the URL of a clicked link?

Hello! I am using the .NET Web Browser control (not Microsoft Web Browser COM). How can I code this: When the user clicks on a link that will open a new window/tab, instead of opening Internet Explorer with the link, it creates a new tab and navigates to that link (my web browser is tab based). I just need help getting the URL of the clicked link so that the web browser control on the new tab can navigate to it. Any help?

Matt

[432 byte] By [MateuszRajca] at [2007-12-22]
# 1

Hi,

you could use the Navigating event to catch user click on the link (not the same thing, but close)...:

private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (CheckForSpecificUrl(e.Url))
{
e.Cancel = true;
OpenNewTab(e.Url);
}
}

Setting e.Cancel to true will cancel the navigation and the url won't change...

The above CheckForSpecificUrl method would return true, if the clicked link has to open in a new tab (you can test the url address for some patterns and decide, which urls you want to let navigate in the same window and which not. OpenNewTab method should create a new tab, containing a new WebBrowser control.

Hope this helps,

Andrej

AndrejTozon at 2007-8-30 > top of Msdn Tech,Visual C#,Visual C# General...