I tried a variety of jQuery plugins for warning the user when they are about to leave a form with unsaved changes, and I couldn’t quite get any of them to behave exactly the way I wanted. Among other reasons, I needed to support TinyMCE and jQuery tabs. Anyway, I ended up rolling my own, which I’m making available in case it might help somebody else. Here’s the file, usage instructions are in the source comments:
Note that this plugin relies on the onBeforeUnload event, which I think is only supported by IE and Firefox, but it works better and is less complicated than other solutions that don’t rely on that event. An unfortunate tradeoff. I wish that event were more widely supported.