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?
Asked
Active
Viewed 741 times
2
-
1What is _C# WebBrowser_? – jrummell May 29 '12 at 12:48
-
The component of C#. Is there anything wrong? – Willy May 29 '12 at 12:50
-
Willy, you am everything right. – Daniel Earwicker May 29 '12 at 12:51
-
1Check out this answer to [Read Javascript variable from Web Browser control](http://stackoverflow.com/a/6879120/205233) - it should give you a starting point. – Filburt May 29 '12 at 12:54
-
So you really meant the [WinForms WebBrowser control](http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx), right? – jrummell May 29 '12 at 12:56
-
Yeah, that is what I use. I edited my question again. – Willy May 29 '12 at 12:59
1 Answers
2
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.
-
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. – Willy May 29 '12 at 13:48
-
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: http://notions.okuda.ca/2009/06/11/calling-javascript-in-a-webbrowser-control-from-c/ – Turnkey May 29 '12 at 13:54