The obvious question to ask is: why? And the only answer I have is: because I could. This is the third time I've written an implementation of Minesweeper, and the second one in JavaScript (see here for my first effort, which only works properly in IE).

The aim was to write a perfect replica of the Windows game as far as the board itself goes, which I think I've achieved. I also aimed to make the game easily customisable in terms of look and behaviour, so the version you see has a fair amount of presentation code in the page that hooks into events in the main game script. I don't really expect anyone would want to use my code, but it pleases me to know that someone could.

I expected it to be easy to program and by and large it was, though as ever with such projects I learned a few things unexpectedly along the way, which I will document another day.

UPDATE January 2010: I've updated the mouse button detection and it now works properly on WebKit.

Supported browsers:
  • IE 5+ on Windows
  • Firefox/Mozilla/Netscape 6+ (earlier versions of Mozilla may have minor layout issues)
  • Safari 3+
  • Google Chrome
Incompletely supported browsers:
  • Opera 7.5+