473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Web Browser Help - Get URL of 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
Aug 1 '06 #1
3 22552
Hey Matt,

Here is the code that works for me when I tested this out:

public Form1()
{
InitializeComponent();

// probably just easier to add this event in from the visual
editor
this.webBrowser1.NewWindow += new
System.ComponentModel.CancelEventHandler(this.webB rowser1_NewWindow);
this.webBrowser1.Navigating += new
System.Windows.Forms.WebBrowserNavigatingEventHand ler(this.webBrowser1_Navigating);
}

private void webBrowser1_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
// the URL that it is going to..
MessageBox.Show(webBrowser1.StatusText.ToString()) ;

// you can just let the browser handle this since it can just
navigate within its current frame... but you could handle it here too

// tell system we want to handle this event ourselves
// e.Cancel = true;
} // end webBrowser1_Navigating ()
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
// the URL that it is going to..
MessageBox.Show(webBrowser1.StatusText.ToString()) ;

// Load webBrowser1.StatusText.ToString() in new tab

// tell system we want to handle this event ourselves
e.Cancel = true;

} // end webBrowser1_NewWindow ()

"Mateusz Rajca" wrote:
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
Aug 1 '06 #2
Doesnt work. Can you email me a sample:

ma**********@gmail.com

Matt

"RobKinney1" wrote:
Hey Matt,

Here is the code that works for me when I tested this out:

public Form1()
{
InitializeComponent();

// probably just easier to add this event in from the visual
editor
this.webBrowser1.NewWindow += new
System.ComponentModel.CancelEventHandler(this.webB rowser1_NewWindow);
this.webBrowser1.Navigating += new
System.Windows.Forms.WebBrowserNavigatingEventHand ler(this.webBrowser1_Navigating);
}

private void webBrowser1_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
// the URL that it is going to..
MessageBox.Show(webBrowser1.StatusText.ToString()) ;

// you can just let the browser handle this since it can just
navigate within its current frame... but you could handle it here too

// tell system we want to handle this event ourselves
// e.Cancel = true;
} // end webBrowser1_Navigating ()
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
// the URL that it is going to..
MessageBox.Show(webBrowser1.StatusText.ToString()) ;

// Load webBrowser1.StatusText.ToString() in new tab

// tell system we want to handle this event ourselves
e.Cancel = true;

} // end webBrowser1_NewWindow ()

"Mateusz Rajca" wrote:
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
Aug 1 '06 #3
I just sent it through my gmail account. I hope I undetstand the question
correctly.

Rob K

"Mateusz Rajca" wrote:
Doesnt work. Can you email me a sample:

ma**********@gmail.com

Matt
Aug 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Tony Marston | last post by:
If the use of the browser's BACK button is interfering with the operation of your web application then take a look at this article entitle "Back Button Blues" ...
10
by: Simon Wigzell | last post by:
Is there any way to create and open a window in javascript so that links in other websites won't "steal" it? I've written a web page with a form for people to enter headlines and URLs from...
7
by: George | last post by:
I am trying to set up a login-logout website. I have a cookie about the login status. I put it as logout once the logout link is clicked. And I put a little security check about the status of...
3
by: Bond | last post by:
how do I know when the browser is making a request to the server? I am not having an onclick event for EVERY hyperlink, submit, etc. There must be some javascript function that I can overwrite...
13
by: zn | last post by:
How can I cause a link on a page to open up a new browser window when the link is clicked on? I've noticed javascript code sometimes when I try to right-click a link and open it in another window....
1
by: Audrey | last post by:
Hi Need some advice here.. I have a frame with a hyperlink to logout from the site When the Logout link (on the left frame) is clicked, a page stating "You've logged out. Please login again" is...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a...
3
by: Jason | last post by:
Hi, I built a vb.Net application that creates ICS calendar files dynamically and then sends them to the client browser as a downloadable file. Works perfectly except in the following situation....
1
by: db007 | last post by:
Hi, I have a problem with a current project and the scroll position. I have an AJAX enabled website using Visual Studio 2005 and ASP.Net 2.0. The project also uses masterpages. On the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.