Skip to content Skip to sidebar Skip to footer

Js - Check If A Webpage Is Closed

I am attempting to fire an event on the action of a webpage closing. The scenario is - a website opens with a separate window, which the user may choose to minimize. This minimized

Solution 1:

Well, this is just not possible as there is no WINDOW_CLOSED event because window objects displayed like main window of a browser fall under the rights of the underlying OS. Even in cases where TDI( Tabbed Documents Interface ), like Microsoft's MDI is implemented in the browsers, no event is fired upon closing of a tab.

Solution 2:

var winObj = null; var SixView = function (a,b,c) { var popUpPageUrl = "../ViewDrawing.aspx?a=" + $('[id*=hdnAhuId]').val() + "&compPosition=" + spobtId + "&sectionName=" + c; winObj = myOpenWindow(popUpPageUrl, "myWin", winObj); }

functionmyOpenWindow(winURL, winName, winObj) {
    var theWin; // this will hold our opened window // first check to see if the window already existsif (winObj != null) {
        // the window has already been created, but did the user close it?// if so, then reopen it. Otherwise make it the active window.if (!winObj.closed) {
            var result = confirm("Do you want to save the changes made in six view drawing ?");
            if (result) {
                saveChanges();
            }
            winObj = window.open(winURL, winName);
            winObj.focus();
            return winObj;
        }
        // otherwise fall through to the code below to re-open the window
    }

    // if we get here, then the window hasn't been created yet, or it// was closed by the user.
    theWin = window.open(winURL, winName);
    return theWin;
}

Post a Comment for "Js - Check If A Webpage Is Closed"