Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7430407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:08:08+00:00 2026-05-29T09:08:08+00:00

What I want to do is when WPF WebBrowser loads page I just want

  • 0

What I want to do is when WPF WebBrowser loads page I just want to put over page content some to prevent any click events from user within downloaded page.

So the idea is somehow insert that including it style into downloaded page…

Is it possible to do?

If yes, then how it could be implemented in C#?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:08:09+00:00Added an answer on May 29, 2026 at 9:08 am

    Can you navigate to a javascript: URL? That’s probably the cheap way to do it, and I believe that’s what I ended up doing in the past.

    There’s another way involving directly accessing the DOM. It involves accessing WebBrowser.Document, which you can cast to a COM type. I’ll need to get back to you on the exact technique–I have it saved somewhere–but there’s a tiny bit of a hint on MSDN.

    Edit:

    The easiest way to test the JavaScript would be to do something like:

    webBrowser.Navigate("javascript:alert('Test');")
    

    If you get a dialog saying Test without your web page disappearing, it works. You can insert any JavaScript you want there, provided the test worked. For example:

    webBrowser.Navigate("javascript:void(document.body.innerHTML = '<div>Test</div>' + document.body.innerHTML);");
    

    The Proper Way

    I’m going to give this a shot, but it’s untested, so keep in mind that you might need to tweak this process a bit.

    1. Reference to ShDocVw.dll.
    2. Add a using statement for the mshtml namespace.
    3. Cast the WebBrowser.Document object to an mshtml.IHTMLDocument2 interface.
    4. This should give you access to the document’s DOM, so you should be able to use IntelliSense to figure out what to do from here. You’ll be using COM, though, so it will be a bit of a pain, and will require a lot of work with interfaces.

    Edit: This question has some good examples. I would use plain casting instead of the as keyword, though. obj as Something is syntax sugar for obj is Something ? (Something)obj : null. That extra test really is unnecessary here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to put over WPF WebBrowser some UIElement (opacity = 0) ie and
I am using WPF WebBrowser control and I want to acces some of the
I want to set up inline content of a WPF WebBrowser control: <WebBrowser> <html>
I have a WPF WebBrowser Component, and I want to set the uri from
I want to scrap the content of an asp-based web pages from WPF application,
I want to learn WPF but from all the commentary I've been hearing the
I want to make impossible checking checkbox in WPF (from C# code). Only unchecking
Doing some 3D stuff in wpf- want to use a simpler test to see
G'day! I want my WPF ComboBox to display some alternative text when its data-bound
I am using a WebBrowser component in WPF to host some JavaScript + HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.