HTML 文件中的 javascript 调试

发布于 2024-09-15 16:37:57 字数 77 浏览 1 评论 0原文

如何在 javascript 函数的 HTML 页面中放置断点,以便在执行行时查看变量的值。这样做最简单的方法是什么?

谢谢

How can I put break points in an HTML page in javascript functions to see values of variables as lines get executed. What is the easiest way of doing so?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

暗地喜欢 2024-09-22 16:37:57

使用关键字“debugger;”尝试调用硬断点。

只要您的浏览器启用了 Javascript 调试,那么 debugger; 语句就会告诉它执行此操作,您将进入逐步调试器。

Firefox 的 Firebug 扩展是迄今为止最简单的,但 Internet Explorer 的新内置“开发人员工具”选项也相当不错。我必须说 Firebug 更容易、更完善,但我经常必须在一堆不同的浏览器中进行验证,在某些情况下只能在 Internet Explorer 中进行验证,例如调试客户端 Javascript 和自定义 ActiveX 控件的交互时。

debugger;”语句似乎始终是跨平台和浏览器快速进入调试器的金钥匙,而无需跳过一堆麻烦的事情。

因此,您可能有一些像下面这样的 Javacscript 块,浏览器会在“debugger;”上调用逐行调试器,就像它是一个断点一样...

var a = 5;

var b = 6;

调试器;

a = b;

Use the keyword "debugger;" to attempt invoking a hard breakpoint.

As long as your browser has Javascript Debugging enabled, then the debugger; statement will tell it to do it's thang and you'll be in a step-by-step debugger.

The Firebug extension for Firefox is by far the easiest, but Internet Explorer's new built-in "Developer Tools" option is quite nice too. Firebug I must say is easier and more polished, but I often must validate in a pile of different browsers and in some cases only Internet Explorer like when debugging the interaction of client-side Javascript and a custom ActiveX control.

The "debugger;" statement always seems to be the golden key to quickly get in to a debugger across platforms and browsers without jumping through a bunch of burning hoops.

So you might have some block of Javacscript like the following, and the browser would invoke the line-by-line debugger on "debugger;" like it was a breakpoint...

var a = 5;

var b = 6;

debugger;

a = b;

垂暮老矣 2024-09-22 16:37:57

您应该获得 Firebug

You should get Firebug.

谁与争疯 2024-09-22 16:37:57

在 Google Chrome 浏览器中按“Ctrl+Shift+i”按钮。

在IE浏览器中:
- 下载 Microsoft Javascript 调试器。
- 在浏览器中转到“工具 -> Internet 选项 -> 高级”并从“禁用脚本调试器”复选框中删除“V”。
享受。

In Google Chrome browser press 'Ctrl+Shift+i' buttons.

In IE browser:
- Download Microsoft Javascript debugger.
- In browser goto "Tools->Internet Options->Advanced" and remove "V" from "Disable script debugger" check-box.
Enjoy.

脱离于你 2024-09-22 16:37:57
alert(variable);

这就是我所做的,它的工作原理与断点完全相同。当您按“确定”时,脚本将继续。

alert(variable);

This is what I do, it pretty much works exactly like a breakpoint. When you press 'OK' the script continues.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文