有一个page1.html (我在浏览器中打开它):
<div id="content">
</div>
<script type="text/JavaScript">
jQuery.ajax({
type : "GET",
url : 'page2.html',
dataType : "html",
success : function(response) {
jQuery('#content').append(response);
}
});
</script>Page2.html的代码:
<script type="text/JavaScript" src="js/page2.js"></script>
<script type="text/JavaScript">
test();
</script>js/page2.js页面代码:
function test() {
alert('Function Test()');
}一切正常,"Function Test()“窗口被显示出来。但问题是我无法访问firebug js调试器中的函数test()的代码。它既不出现在事件脚本中,也不出现在eval中。
我怎么才能修复它呢?
仅供参考:如果我不把函数放在单独的js文件中,而是放在page2.html中,它会直接出现在调试器中。
如果我将"debugger“一词放入test()函数中,Firebug就会停止,但该函数的源代码仍然不可用。
版本: Firefox 3.0.10,Firebug 1.3.3
更新:与问题Making Firebug break inside dynamically loaded javascript基本相同,但还没有答案
发布于 2009-05-17 11:24:58
这是一个技巧,但是我通过添加两次调试器这个词,让firebug在外部文件js/page2.js中停止。一次在文件的顶部,另一次在函数的顶部。
如果调试器字在这两个位置中只出现一次,则firebug不会停止。
debugger;
function test() {
debugger;
alert('Function Test()');
}发布于 2009-05-17 11:01:38
将js/page2.js更改为:
function test() {
alert('Function Test()');
}
alert('loaded');您看到“已加载”消息了吗?
发布于 2011-03-06 20:29:43
尝试:
eval('debugger;');它不是很漂亮,但看起来很有效。
https://stackoverflow.com/questions/874256
复制相似问题