Debugging JavaScript in Internet Explorer and Safari

Currently, I don’t really have a good method of debugging JavaScript in Internet Explorer and Safari. In Firefox, you can use Firebug’s logging feature and command Line functions. However, this doesn’t help me when I move to other browsers.

Answer

For Safari you need to enable the “Develop” menu via Preferences (in Safari 3.1; see the entry in Apple’s Safari development FAQ) or via

$ defaults write com.apple.Safari IncludeDebugMenu 1

at the terminal in Mac OS X. Then from the Develop menu choose Show Web Inspector and click on the Console link. Your script can write to the console using window.console.log.

For Internet Explorer, Visual Studio is really the best script debugger but the Microsoft Script Debugger is okay if you don’t have Visual Studio. This post on the IE team blog walks you through installing it and connecting to Internet Explorer.

Internet Explorer 8 looks like it will have a very fancy script debugger, so if you’re feeling really adventurous you could install the Internet Explorer 8 beta and give that a whirl.