How to ask before closing a window

0

Hello everyone, I have a window that is created from javascript and I would like you to ask the client for a confirmation to close when I close, I have tried this:

var xwin = window.open("/PatientForms/RenderDinamicHtml", "", 
"width=800,   
height=540,scrollbars=yes,resizable=no,fullscreen=no");

$(xwin).bind("beforeunload", function () {
return confirm("Do you really want to close?");
});

My previous code closes the window before confirmation.

Could someone help me

    
asked by Raidel Fonseca 02.01.2019 в 22:16
source

1 answer

1

You can try this:

window.onbeforeunload = function(e) {
       return '¿ Quieres salir?';
};
    
answered by 02.01.2019 / 22:36
source