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?

6
  • 1
    What is C# WebBrowser? Commented May 29, 2012 at 12:48
  • The component of C#. Is there anything wrong? Commented May 29, 2012 at 12:50
  • Willy, you am everything right. Commented May 29, 2012 at 12:51
  • 1
    Check out this answer to Read Javascript variable from Web Browser control - it should give you a starting point. Commented May 29, 2012 at 12:54
  • So you really meant the WinForms WebBrowser control, right? Commented May 29, 2012 at 12:56

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.