Unable to use Console.Log() within a WebBrowser Control

前端 未结 2 1155
情歌与酒
情歌与酒 2020-12-17 04:43

So I\'m writing a Javascript coding UI using C# Windows Forms. This is my code for when the \"Run\" button is pressed, in case it helps:



        
2条回答
  •  春和景丽
    2020-12-17 05:36

    You can get JavaScript console output from within Visual Studio.

    By default the webBrowser1 control uses IE7 to render it's output. IE7 does not have a console.log() function. In order to get the console.log() function to work, you need to add the following meta tag:

    
    

    'IE=8' or greater should make the console.log() available to you.

    When you debug a Windows Forms application it debugs using the .NET Managed Code debugger. In order to debug differently, instead of pressing 'Play' to debug, try selecting "Debug" > "Start without Debugging". Now once your application is running, go to "Debug" > "Attach to Process" and find your WindowsFormsApplication.exe, attach to it using the Script Code Debugger instead of the .NET Managed Code debugger.

    Now, in Visual Studio:

    • You can open "Debug" > "Windows" > "JavaScript Console"
    • You can also open "Debug" > "Windows" > "DOM Explorer"

提交回复
热议问题