8

I have a .NET app that runs an embedded web browser (System.Windows.Forms.WebBrowser). I can't figure out how to access the web console that I can normally access by pressing f12 (equivalent to firebug's console). Is there a way to enable this? Also is it possible to redirect this output to a file?

John Saunders
  • 157,405
  • 24
  • 229
  • 388
sworded
  • 2,239
  • 3
  • 28
  • 45
  • Why do you need the console? What are you trying to get? – Bestter Oct 02 '12 at 15:34
  • 1
    I would like to debug into the embedded web browser application. – sworded Oct 02 '12 at 15:53
  • The web browser class is using Internet Explorer: then test your application with different version of IE, on different version of Windows (XP, Vista, Seven) and different processor type (32 or 64 bits). Source: http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser(v=vs.100).aspx – Bestter Oct 02 '12 at 15:56

3 Answers3

14

Have you tried using FirebugLite ?

https://getfirebug.com/firebuglite

Include this script inside your page and you will have a lite version of firebug which you can use to debug your JS.

<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>
Amitd
  • 4,691
  • 8
  • 51
  • 82
  • I only have control over the .NET application and not the website content. – sworded Oct 02 '12 at 19:44
  • You can inject javascript in the browser after the page is loaded – Stefan P. Oct 02 '12 at 21:07
  • Try this answer for injecting script http://stackoverflow.com/questions/153748/how-to-inject-javascript-in-webbrowser-control – Amitd Oct 03 '12 at 06:53
  • 4
    This works wonderfully for embedded browser. Just add in the main HTML tag to get it displayed by default. Thanks! – Kloe2378231 Nov 03 '15 at 09:05
  • 1
    Lifesaver! I'm trying to get to the bottom of Google Maps for Work authorisation using an embedded WebBrowser control in a desktop application (probably doomed to failure) and your suggestion is the only way I've found to see the helpful error message from Google that's written to console.error(). No point testing in a browser because the message contains the HTML file location that Google is seeing (which is the issue). – Jon Mar 15 '16 at 18:12
3

The embedded web browser does not support ActiveX controllers, so there is no web console.

Stefan P.
  • 9,419
  • 5
  • 26
  • 43
  • Are all browser web consoles based on ActiveX? (ie, firefox and chrome) – sworded Oct 02 '12 at 15:54
  • Firefox and Chrome does not support ActiveX controls because it's a Microsoft technology :)) – Stefan P. Oct 02 '12 at 15:57
  • Is it possible to access the web console of another embedded browser? (other than IE) – sworded Oct 02 '12 at 15:59
  • I've tried to use several components to embed Geko (FF) and Webkit (Chrome) but every time it was a major bug like no printing options or freezing, so I've decided to stick to the IE, you can read more about this here http://stackoverflow.com/questions/790542/replacing-net-webbrowser-control-with-a-better-browser-like-chrome – Stefan P. Oct 02 '12 at 16:03
0

you can use virtual studio to debug it

  1. start app
  2. Open "attach to dialog" by debug->attach to process
  3. In attach to selection,select "Script"
  4. Then select the process you want to debug
Ming
  • 887
  • 1
  • 6
  • 5