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
Why are you doing browser-sniffing here? The "Firefox" branch of your code is returning the return value of window.confirm, which is a boolean. But a boolean isn't callable, so assigning it to window.onbeforeunload is the same as assigning null.
What you probably want to do is remove the browser-sniffing and just do:
window.onbeforeunload = confirmExamClose;