gpt4 book ai didi

c# - 在 WebBrowser 控件中调试 HTML

转载 作者:太空狗 更新时间:2023-10-29 14:02:07 24 4
gpt4 key购买 nike

我需要将 HTML 嵌入到 Winforms 项目中并从中调用 Javascript 函数。我在 c# 项目中使用 webBrowser 控件并调用:

webBrowser.Navigate("website");
return webBrowser.Document.InvokeScript("myMethod", new object[]{"test"});

当调试器在“myMethod”中时,如何调试代码的执行?

这篇文章介绍了如何从 IE 调试 HTML: http://www.codeproject.com/Articles/18921/Using-Visual-Studio-to-Debug-JavaScript-in-IE

虽然我不知道它有多相关。

最佳答案

在您网站的“myMethod”函数中添加以下“调试器”行 -\

function myMethod(arg1, arg2)
{
// when myMethod executes you will get prompt that with which
// debugger you want to execute
// then from prompt select "New Instance of Visual Studio 2xxx"
debugger;

//
...
...
}

“调试器”语句将提示调试 JavaScript。

当 myMethod 执行时你会得到提示要执行的调试器,然后从提示中选择“Visual Studio 2xxx 的新实例”

希望这会有所帮助。

关于c# - 在 WebBrowser 控件中调试 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12036592/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com