Of all the browsers, it seems that only Opera doesn't support onunload/onbeforeunload events. (It's been fifteen years now, Opera!) Solutions for this issue have been covered many times, here for example: [onbeforeunload support detection](https://stackoverflow.com/questions/158673/onbeforeunload-support-detection)

Unfortunately, as of Opera 11.51, `("onbeforeunload" in window) == true`, but the actual onbeforeunload event is never executed!

My web application needs to send data to server when a user leaves the page; I'm using a synchronous ajax request for this. It looks like I have to resort to using a "Save" button somewhere on the page to cover up for Opera issues. However, I don't want this button to confuse users whose browsers are capable of auto-saving through ajax, so I'd really like the button to only show up in Opera.

Is my only choice browser-detection? The problem is, Opera has an option to disguise itself as other browsers anyway.