Row and column in Javascript error event attributes

I decided that there are some errors that I do not want to access the browser error handler. But I still want to know about them. In my actual code, I have a function that stores errors in a hidden element, and ajax sends them to the database. The following is a simplified version of the try block:

try
{
  newValueEvaled = eval(newValue);
}catch(err)
{
  alert("Error caught: Line " + err.lineNumber + ((err.columnNumber != undefined)?', Column:' + err.columnNumber:"") + '\n' + err.message);
}

I also need columnNumber. Currently, it never exists, but somehow the browser error console has access to it. Can someone tell me how can I access it?

+3
source share
2 answers

, JavaScript, . Firebug/WebKit/ IE , , , .

+3

, , :

function dumpErrors(error, file, line, column)
{
    alert('Error: ' + error + ', occurred in file: ' + file + ', on line: ' + line + ', at column: ' + (column || 'unknown'));
}
onerror = dumpErrors;

"" . "" Chrome ( 30.0+), Firefox ( 17, Linux).

+3

All Articles