Javascript 如何让firefox报告javascript错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4709982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 13:43:12  来源:igfitidea点击:

How to make firefox report the javascript error?

javascriptdebuggingfirefoxfirebug

提问by Bin Chen

I am developing with Firefox and Firebug, but in my environment if the js has the syntax error, the firefox will not report any error, it just stops there.

我是用 Firefox 和 Firebug 开发的,但是在我的环境中,如果 js 出现语法错误,firefox 不会报告任何错误,它只是停在那里。

Then I have to use IE to reload the page, IE will report the error at the bottom left corner, and after clicking it I can see the line number of the js error.

然后就得用IE重新加载页面,IE会在左下角报错,点击后可以看到js错误的行号。

I am wondering if I misconfigured something? I think at least firebug should report the error as IE does. But firebug displayed nothing.

我想知道我是否配置错误?我认为至少 firebug 应该像 IE 一样报告错误。但萤火虫什么也没显示。

The example code(show error in IE but normal in FF):

示例代码(在 IE 中显示错误但在 FF 中正常):

<!DOCTYPE html>
<html>
<head>
  <style>
  body { color:blue; }
  </style>
  <script src="http://code.jquery.com/jquery-1.4.4.js"></script>
</head>
<body>
<script>
    if (a < ) 0 {
    }

</script>

</body>
</html>

采纳答案by jmort253

To configure Firebug to show errors, do the following:

要将 Firebug 配置为显示错误,请执行以下操作:

  • Click the arrow on the Console tab.
  • Make sure it's Enabled.
  • Make sure "Show JavaScript Errors" is checked.
  • 单击控制台选项卡上的箭头。
  • 确保它已启用。
  • 确保选中“显示 JavaScript 错误”。

You should see the errors in the console now, and it should show you the line number and filename.

您现在应该会在控制台中看到错误,并且应该会显示行号和文件名。

I am using Firefox 3.6 and Firebug 1.5.0.

我使用的是 Firefox 3.6 和 Firebug 1.5.0。

UPDATE:This same process also works in the latest Firefox Nightly 19.0a1, using Firebug 1.10.4. Thus, these instructions are still up to date.

更新:同样的过程也适用于最新的 Firefox Nightly 19.0a1,使用 Firebug 1.10.4。因此,这些说明仍然是最新的。

回答by xiaowl

I think you may enable the 'Script' option. With this option on, while a js error occurs, firefox stops caused by the breakpoint of js source where error occurs.

我认为您可以启用“脚本”选项。开启此选项,当发生js错误时,firefox会因发生错误的js源断点而停止。