pennypacker.net: Debugging Javascript in Safari

Debugging Javascript in Safari

Since I've taken javascript under wing again, and have been working with it more and more, I've come to love Firefox and its Javascript Console for reporting errors and messages. It makes development much more simple because javascript tends to just do things, and if you're like me, you might have no idea what went wrong.

The unfortunate part is that Safari does not have such a feature. I've written a script that works like gangbusters in Firefox, but does next to nothing in Safari. Well, there is a way to get Safari to share some information, but you have to get under the hood to do it.

The first thing that a Safari user needs to do is activate the Debug menu that Apple has kindly hidden from view. To do this, fire up the Terminal, and enter the line:

defaults write com.apple.Safari IncludeDebugMenu 1

Once that's done, restart Safari, and you ought to see the Debug menu right up top next to Help. Select "Log Javascript Exceptions" in that pulldown menu so that there is a check mark next to it.

Then, simply open up the Console (found in the Utilities folder), and presto! Fine and dandy little messages are logged when Safari runs into problems. For example, it seems the problem I'm having is this:

2005-03-25 14:59:27.488 Safari[4133] starting sample tool

(event handler):Value undefined (result of expression getXcoords) is not object. Cannot be called.

It may not be the most detailed log, but it's better than fumbling around in the dark!

under:
Web Development
Posted on
2005-03-25

Comments:

There are no comments on this article.

This article is closed to further commentary. But you can always contact me directly.

Skip the sidebar

All things related to web design and development with a nice focus on using standards and accessibility

Recent Articles
Badges
  1. XHTML
  2. CSS
  3. 508
  4. RSS