Apr 8, 2008

Debugging Javascript

A few tips and tricks that will make life easier when debugging client-side web apps:
  • The address bar is your friend. Use the javascript: protocol handler to execute any script command within the context of the current document. For instance, typing javascript:alert(document.cookie) into the address bar will spit out all cookies associated with the page. Likewise, javascript:alert(document.body.innerHTML) will spit out the HTML within the body tag of the loaded document.

  • Ctrl-A + Ctrl-C is your friend. Copying from alert boxes in the browser works just like copying from a text field of any other application.

For more advanced debugging, check Rob Chartier's article on debugging Javascript.

No comments: