动态加载的js函数不会出现在Firebug js调试器中 [英] dynamically loaded js function does not appear in Firebug js debugger

查看:186
本文介绍了动态加载的js函数不会出现在Firebug js调试器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个page1.html(我在浏览器中打开它):

There is a page1.html (I open it in browser):

<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的代码:

Code of the page2.html:

<script type="text/JavaScript" src="js/page2.js"></script>

<script type="text/JavaScript">
test();
</script>

页面代码js / page2.js:

Code of the page js/page2.js:

function test() {
    alert('Function Test()');
}

一切都很好,显示Function Test()窗口。但问题是我无法在firebug js调试器中达到函数test()的代码。它不会出现在事件脚本和eval中。

Everything works well, the window "Function Test()" is shown. But the problem is that I can't reach the code of function test() in firebug js debugger. It doesn't appear in event scripts nor in eval.

我该如何解决?

FYI:
如果我不把函数放在单独的js文件中,但将其放在page2.html中,则
出现在调试器corectly中。

FYI: If I don't put the function in separate js file, but place it in page2.html, it appears in debugger corectly.

如果我在test()函数中放置debugger字样,Firebug停止,但该函数的源代码仍然无法访问。

If I put "debugger" word in test() function, Firebug stops, but the source code of the function is still unreachable.

版本:Firefox 3.0.10,Firebug 1.3.3

Versions: Firefox 3.0.10, Firebug 1.3.3

更新:与问题使Firebug内部动态加载的javascript ,但没有答案

Update: pretty much the same as the question Making Firebug break inside dynamically loaded javascript, but there is no answer yet

推荐答案

p>这是一个黑客,但是我通过在调试器中添加两次来阻止外部文件 js / page2.js 中的firebug。一旦在文件的顶部,另一次在功能的顶部。

It's a hack, but I got firebug to stop in the external file js/page2.js by adding the word debugger twice. Once at the top of the file and another time at the top of the function.

如果调试器字在任何一个地方只有一次,则firebug不会停止。

If the debugger word is there only once in either place, firebug does not stop.

debugger;
function test() {
    debugger;
    alert('Function Test()');
}

这篇关于动态加载的js函数不会出现在Firebug js调试器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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