2

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?

Willy
  • 1,828
  • 16
  • 41

1 Answers1

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.

Community
  • 1
  • 1
Turnkey
  • 9,266
  • 3
  • 27
  • 36
  • 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