在Chrome开发者工具中看不到动态加载的代码22 [英] Can't see dynamically loaded code in Chrome Developer Tools 22

查看:254
本文介绍了在Chrome开发者工具中看不到动态加载的代码22的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过AJAX动态加载包含javascript的html片段时,在Chrome 22.0.1229.94的开发人员工具窗口的源"标签中看不到该内容.告诉我,我去了这里

When I dynamically load a snippet of html containing javascript via AJAX, I cannot see that content in the source tab in the developer tools window in Chrome 22.0.1229.94. Tellingly, I went here

https://developers.google.com/chrome-developer-tools/docs /scripts-breakpoints#js_dynamic

此页面显示了示例开发者工具窗口,该窗口已过时.页面上有一个按钮可以加载动态脚本,执行该操作时它不会显示在源"选项卡中.

This page shows an example developer tools window which is out of date. There is a button on the page to load a dynamic script and it does not show up in the source tab when you do.

作为一种解决方法,我发现添加

As a work-around, I have found that adding

debugger;

脚本并重新加载它会导致它在动态加载的代码中暂停,但是不幸的是,所有行号都显示为灰色,并且您无法在调试器中设置任何断点.

to the script and reloading it will cause it to pause in the dynamically loaded code, but unfortunately, all the line numbers are greyed out and you can't set any breakpoints within the debugger.

我在这里还是在想什么?

Am I missing something here or what?

谢谢, 罗布

推荐答案

使用动态加载的库或javascript代码时,可以使用短语

When you use a library or javascript code that you have loaded it dynamically, you can use the phrase

//@ sourceURL=foo.js

在您的JavaScript代码的开头, foo.js 是将为其分配的名称.调试器将使用该名称显示它. 在chrome中,这是正确的,我也认为在萤火虫中也是如此. 在这种情况下,您可以在动态加载的javascript代码中放置一个断点.

at the beginning of your javascript code that foo.js is the name that will be assigned it. debugger will show it with that name. This is true in chrome, and I think in firebug too. In this case you can place a breakpoint in the dynamically loaded javascript code.

这篇关于在Chrome开发者工具中看不到动态加载的代码22的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆