Q: JavaScript code not working in Firefox for ASPX web site I have the following JS code that helps signing out a session from an ASPX page so a 'log out' record can be stored in a database. The code works when the site is opened with IE11, EDGE, and Chrome. Using those three browsers the user gets the popup asking if staying on the site or leaving the site. When it comes to be tested in Firefox, at least version 54, it just does not work. Nothings pops up.
Code is:
//We want to capture when a user logs out from the system - this is a way to force the browser to log out the session

window.onbeforeunload = closingCode;
function closingCode() {
    // when user clicks the 'X' from the browser, will be prompted to leave or to stay
    //clicking any of the options will trigger an event that will capture when the session was logged out and saved in the db
    var button = document.getElementById('btnLogout');
    button.click();
    return "You are closing or refreshing this site. Clicking 'Stay on this page' will log out your session. Clicking 'Leave this page' will close your window.";
    //return null;
}
//this will prevent the popup to appear everytime user navigates between pages/links 
$(document).ready(function () {
    $('a[rel!=ext]').click(function () {
        window.onbeforeunload = null;
    });
    $('form').submit(function () {
        window.onbeforeunload = null;
    });
});

