AppleScript Programming/Sample Programs/Safari Quit Warning

Note: This script is obsolete for its purpose, since by these days Safari prompts user for confirmation if there is more than one window/tab open while quitting. But as the code itself is valid, it may be kept as a general example.

This is quite much doing same than Firefox's alert box that pops up when you're about to quit the browser with more than one window/tab open.

I use external tool (iKey) to force this script to be run when cmd+Q is hit while Safari is active application. I just plain hate it, when I mispress it instead of cmd+W or opt+Q.