I'm using `window.onbeforeunload` to display a message to the user on windows close, the function works well with Chrome and IE but it doesn't work with Firefox, I'm using Firefox version `26.0` I have tried many but with no mean, somebody said that its a bug in Firefox as in this [post](https://stackoverflow.com/questions/3727216/window-onbeforeunload-support-in-firefox) and another suggests some solutions as in this [post](https://stackoverflow.com/questions/14645011/window-onbeforeunload-and-window-onunload-is-not-working-in-firefox-safari-o) I tried all the solutions available using Javascript and jQuery but it doesn't work, now I display a confirm dialog but the browser default dialog appears after it and I'm not satisfied with that, I tried also to prevent the browser default dialog from appearing using `preventDefault()` but also with no mean! if there's any solution to this problem it will be great, here's how I used the `window.onbeforeunload`:

```
<script>
window.onbeforeunload = confirmWinClose();
function confirmWinClose() {
     var myVar ='${isFireFox}';
     if(myVar=='true'){
         return confirm(confirmExamClose);
     }else{
         return confirmExamClose;
     }

}
<script>

```

Note:`isFireFox` is a jsp variable that I used to know the type of the browser using `User-Agent` Header and `confirmExamClose` is the message that I display to the user.