1

I was hoping this was simple, I did search but apparently I'm blind.

How do I get the title of the current page I'm on.

I read that I could use wb.Document.Title but it says Title is not a valid option.

I just need it to see if it contains a certain word in it so I can raise an event if so.

Also, some of the pages that I have come across seem to have script errors in them. How do I suppress them so they do not show to the user? I tried wb.ScriptErrorsSuppressed = true; but again, it didn't recognize ScriptErrors Suppressed.

Thanks for your help!

1
  • this is what I found: webBrowser.Document.Title Commented Mar 27, 2011 at 21:41

2 Answers 2

4

To get the title of the doc:

  1. Add a reference to "Microsoft HTML object library" (COM) to the project.
  2. Cast the Document object to HTMLDocument:

    mshtml.HTMLDocument dom = (mshtml.HTMLDocument) browser.Document;

  3. Now you can access the title property:

    Messagebox.Show(dom.title);

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

1 Comment

I found a better way: webBrowser.Document.Title.
0

I found a better way: webBrowser.Document.Title

2 Comments

Doesn't compile as described. If you really have found a simpler way to get the document title than @René's answer, I'd like to see it.
The only way this would work is if you're actually using the WinForms control, which provides more managed stuff, instead of the WPF version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.