简体   繁体   English

Firebug:在断点期间,无法执行控制台语句

[英]Firebug: During breakpoint, can't execute console statement

I'm seeing the following behavior in Firebug: 我在Firebug中看到以下行为:

When the debugger is paused on a breakpoint, if I go to the console and attempt to execute a statement, the Enter key keeps just adding lines instead of executing. 当调试器在断点上暂停时,如果我转到控制台并尝试执行语句,则Enter键只保留添加行而不是执行。

I've tried hitting Shift + Enter and Ctrl + Enter also, to no avail. 我试过按Shift + EnterCtrl + Enter也无济于事。

Environment 环境

I sometimes get this issue on firebug (console), FireFox (dev console), and FireFox developer edition (dev console). 我有时会在firebug(控制台),FireFox(开发控制台)和FireFox开发人员版(开发控制台)上遇到此问题。

Issue 问题

Using the "web console" I would type something like alert("test") and hit the enter key but it would not run. 使用“Web控制台”,我会输入类似alert(“test”)的内容并点击回车键,但它不会运行。

Instead of running it would enter a new line as if I hit "Shift Enter". 而不是运行它将输入一个新行,就像我点击“Shift Enter”。 Oddly when I hit "Shift Enter" just to see what happens, there is no more new line but the code does not run. 奇怪的是,当我点击“Shift Enter”只是为了看看会发生什么,没有更多的新行,但代码没有运行。

Attempt to find a solution 尝试找到解决方案

I restarted my computer, and it went away only to return again later. 我重新启动了我的计算机,它只是稍后再次返回。 I don't have a solution but more of a work around (that works some of the time). 我没有解决方案,但更多的解决方案(在某些时候有效)。 The biggest issue is I don't know what causes this to happen. 最大的问题是我不知道是什么导致这种情况发生。 After may hours I can only guess what I think the issue is. 几个小时后,我只能猜出我认为问题是什么。

I suspect that why this happens is the developer console gets disconnected with the web page that it is trying to debugged. 我怀疑为什么会发生这种情况是开发人员控制台与它正在尝试调试的网页断开连接。

If the Dev tools are disconnected, then it can not run the code (my alert) because it does not know what page/tab to run it on. 如果Dev工具断开连接,则它无法运行代码(我的警报),因为它不知道要在哪个页面/选项卡上运行它。

Work Around 解决

Fully closing all Firefox windows/tabs (and its dev/firebug windows/tabs). 完全关闭所有Firefox窗口/选项卡(及其dev / firebug窗口/选项卡)。 This may-or-may-not re-associate the console with the web page allowing the code to run again. 这可能或者可能不会将控制台与允许代码再次运行的网页重新关联。

Disclaimer 放弃

It works for me most of the time, I would be vary happy if someone (who knows more about this) could explain why this happens and a better solution. 它大部分时间都适合我,如果有人(对此有更多了解)可以解释为什么会发生这种情况并提供更好的解决方案,我会感到高兴。 But until then for anyone else with this issue like me I hope this helps. 但在此之前,对于像我这样的问题,其他任何人都希望这会有所帮助。

I have experienced the same issue, where I would enter (a long) javascript statement in the console and pressing enter would just add new lines instead of running the statements. 我遇到了同样的问题,我将在控制台中输入(一个很长的)javascript语句,按Enter键只会添加新行而不是运行语句。

In my case this was caused by brackets and parentheses that were not balanced. 在我的情况下,这是由括号和括号不平衡引起的。 Once they were balanced, hitting the enter key would execute the statements. 一旦它们平衡,按下回车键将执行语句。

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

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