0

I am trying to intercept a click on the "view source" item on C# WebBrowser's context menu. The default click opens the web page's source in notepad, but I would like, to cancel the default action and open my own form with the source code in a RichTextBox, which is a part of the opening window.

Thanks to Robert I managed to intercept opening right-clicked links in new tabs instead of new windows (Open link in new TAB (WebBrowser Control)), but I was unable to capture the "view source" click.

I would appreciate any advices and solutions to my problem.

Thank you in advance :)

1 Answer 1

0

Late reply, but one way to do it is to reference Microsoft.mshtml and read the source like:

var doc = yourBrowserControl.Document.DomDocument as IHTMLDocument2; txtSource.Text = doc.body.innerHTML; 

However, this method does not give you the complete source (for example, the HEAD section of the source is completely missing).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.