简体   繁体   English

如何使用Chrome浏览器开发者工具调试网页上的脚本?

[英]How can I debug the scripts on my web page using the Chrome browser developer tools?

I have no problem going to Sources, selecting a file and then adding breakpoints for files which are loaded in one by one. 我没有问题去Sources,选择一个文件,然后为一个一个地加载的文件添加断点。 But I have some javascript on my web page within tags. 但是我的网页上的标签中有一些JavaScript。 How can I view, debug this? 我如何查看,调试? I think I have tried everything but I still can't get those few lines of code to appear in the debugger. 我想我已经尝试了所有方法,但仍然无法将那几行代码显示在调试器中。

转到源,然后在其下方的窗格中单击一个图标(左上),然后选择您需要调试的文件

In Chrome, under sources, there is an option to view the actual web page itself. 在Chrome浏览器中,在源代码下,有一个选项可以查看实际的网页本身。 You select that, then find the inline script on that page and set a breakpoint there. 您选择它,然后在该页面上找到内联脚本并在那里设置断点。

Add in your source this code: debugger; 在您的源代码中添加以下代码: debugger; This will automatically stop during debug in your Chrome developer tools. 这将在您的Chrome开发者工具中的调试过程中自动停止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM