Javascript exception stack trace

In Firefox I can get the stack trace of an exception by using exception.stack .

Is there a way to get that in other browsers, too?

Edit: I actually want to save the stack trace automatically (if possible) and not debug it at the time (ie I know how to get the stack trace in a debugger).


Place this line where you want to print the stack trace:

console.log(new Error().stack);

Note: tested by me on Chrome 24 and Firefox 18

May be worth taking a look at this tool as well.


Webkit now has functionality that provides stack traces:

Web Inspector: Understanding Stack Traces, posted by Yury Semikhatsky on Wednesday, April 20th, 2011 at 7:32 am (webkit.org)

From that post:


If you want the string stack trace, I'd go with insin's answer: stacktrace.js. If you want to access the pieces of a stacktrace (line numbers, file names, etc) stackinfo, which actually uses stacktrace.js under the hood.

链接地址: http://www.djcxy.com/p/82434.html

上一篇: 在C#中,如何重新抛出InnerException而不丢失堆栈跟踪?

下一篇: Javascript异常堆栈跟踪