 
So, combine the two for maximal pleasure:
function cavemanLog(message) {
  
  if (window.widget) {
    // Won't display an error box, but will show in the console log.
    window.alert(message);
  } else {
    // Send output to the javascript console.
    window.console.log(message);
  }
} // cavemanLogopen it from the terminal, you get asked if you want to install it (which will move your widget to ~/Library/Widgets, which is really annoying when it drags it out of your development area.  When faced with the dialog, hold down command and option to get a "Run" button.  That'll run the widget in-pace.  If you tun on the devmode:
% defaults write com.apple.dashboard devmode YESYou can drag widgets out of the dashboard area and have them on-screen. Cmd-R will reload the widget.