Is it possible I can detect javascript functions are called when using C# WinForms WebBrowser ? I know it is easy to do it if the javascript functions are my own. But as today I need to browse others' pages, for example, can it be detected when .createElement() or .appendChild() is called?
-
1What is C# WebBrowser?jrummell– jrummell2012-05-29 12:48:05 +00:00Commented May 29, 2012 at 12:48
-
The component of C#. Is there anything wrong?Willy– Willy2012-05-29 12:50:52 +00:00Commented May 29, 2012 at 12:50
-
Willy, you am everything right.Daniel Earwicker– Daniel Earwicker2012-05-29 12:51:26 +00:00Commented May 29, 2012 at 12:51
-
1Check out this answer to Read Javascript variable from Web Browser control - it should give you a starting point.Filburt– Filburt2012-05-29 12:54:01 +00:00Commented May 29, 2012 at 12:54
-
So you really meant the WinForms WebBrowser control, right?jrummell– jrummell2012-05-29 12:56:32 +00:00Commented May 29, 2012 at 12:56
|
Show 1 more comment
1 Answer
You might try to inject some Javascript into the control by appending code to the head, similar to this post: How to Inject Javascript in Web Browser Control. The injected code could be a function to monitor events on a particular DOM element.
2 Comments
Willy
Thanks for reply. I think I have to override the native functions which I want to detect if I do this way. But I still wonder if WebBrowser can provide me more information as it is the one which executes the javascript functions.
Turnkey
You might have the injected Javascript code call back to C# methos to provide the higher level object in your code. This article describes how to do that: notions.okuda.ca/2009/06/11/…