Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If my webBrowser has loaded a page,I want to do like this:
I click the hyperlink on the page,then a MessageBox show me the url of the hyperlink I clicked.And I won't let the page go to the url.In fact,I just want to get the url I clicked.
How can I achieve this?
Posted

Have a look at these links;

Web Browser in C#[^]

http://www.c-sharpcorner.com/Forums/ShowMessages.aspx?ThreadID=46881[^]

http://bytes.com/topic/c-sharp/answers/518523-web-browser-help-get-url-clicked-link[^]

You can use the navigating event to this to get url when you click the hyper link in your web broswer control.
C#
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
      {
      string currentURl= e.Url.ToString());

      }
 
Share this answer
 
v2
C#
private void webBrowser1_Navigating(object sender, NavigatingCancelEventArgs e)
        {
        string currentURl= e.Uri.ToString();
        _addrBox.Text = currentURl;

        }



this was the solution in my case.
maybe someone can use this
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 28-Jun-15 19:32pm    
You should not post answers to threads that do not need a very much specific answer. OP has not asked to show the URL in a control, instead in a MessageBox. Which can be easily used by the currentURI and passed as a parameter.

You have changed the meaning of the post here. I suggest you remove the answer. Or update it to reflect the answer to the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900