<p>I'd like to check if the current browser supports the onbeforeunload event.
The common javascript way to do this does not seem to work:</p>

<pre><code>if (window.onbeforeunload) {
    alert('yes');
}
else {
    alert('no');
}
</code></pre>

<p>Actually, it only checks whether some handler has been attached to the event.
Is there a way to detect if onbeforeunload is supported without detecting the particular browser name?</p>

It would probably be better to just find out by hand which browsers support it and then have your conditional more like:
```
```
if( $.browser.msie ) {
  alert( 'no' );
}
```
```
...etc.
The
```
$.browser.msie
```
is jQuery syntax, most frameworks have similar built-in functions since they use them so much internally. If you aren't using a framework then I'd suggest just taking a look at jQuery's implementation of those functions.