You can't. I ran into this problem yesterday, and it turns out it's a "security feature":
Bug 588292 - Remove site-supplied text for beforeunload and onunload dialogs, and improve button text [
^]
Quite why Mozilla think it's a security problem, when every other browser supports it, I don't know.
The only workaround is to display a message in the "click" event of every element which would cause the page to unload. It's messy and fragile, but it's the only way to display a custom message.