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#?
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:
If you get a dialog saying
Testwithout your web page disappearing, it works. You can insert any JavaScript you want there, provided the test worked. For example: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.
ShDocVw.dll.usingstatement for themshtmlnamespace.WebBrowser.Documentobject to anmshtml.IHTMLDocument2interface.Edit: This question has some good examples. I would use plain casting instead of the
askeyword, though.obj as Somethingis syntax sugar forobj is Something ? (Something)obj : null. That extra test really is unnecessary here.