Confirm dialog with OK ,CANCEL buttons on window close
-
Hi, i have an popup which is an aspx page and when i click on browser close button..., the system should check if there is any unsaved data in the form or not. If there is any unsaved data then the message should be displayed (Do you want to leave..?) with OK and Cancel button... On click of the OK button, the data should not be saved and the user should be returned parent form ie popup should be closed and return to the parent form.On click of the cancel button, the control should return to the Pop. I had tried the below code... window.onbeforeunload = close; function close() { var result=confirm("Do you really want to close this window"); if (result) { return true; } else { location.href = document.URL; } } The above code is not working ie the popup is getting closed even on click of closse button.... and when clicked on OK it is dispalying another msgbox with leave this page and Stay on this page buttons... Please help me regarding the same...
-
Hi, i have an popup which is an aspx page and when i click on browser close button..., the system should check if there is any unsaved data in the form or not. If there is any unsaved data then the message should be displayed (Do you want to leave..?) with OK and Cancel button... On click of the OK button, the data should not be saved and the user should be returned parent form ie popup should be closed and return to the parent form.On click of the cancel button, the control should return to the Pop. I had tried the below code... window.onbeforeunload = close; function close() { var result=confirm("Do you really want to close this window"); if (result) { return true; } else { location.href = document.URL; } } The above code is not working ie the popup is getting closed even on click of closse button.... and when clicked on OK it is dispalying another msgbox with leave this page and Stay on this page buttons... Please help me regarding the same...
I wish the following may solve u issue.
function close() {
var flgDataUnsaved = false; // do your unsave data check here // if there are unsaved data set flgDataUnsaved = true; if ( flgDataUnsaved ){ event.returnValue = "Do you really want to close this window"; }else{ event.returnValue = true; }
}
window.onbeforeunload = close;and u can put a "save" button on your popup page. The user can save the data themselves.
Good day,Good job,Good life
-
I wish the following may solve u issue.
function close() {
var flgDataUnsaved = false; // do your unsave data check here // if there are unsaved data set flgDataUnsaved = true; if ( flgDataUnsaved ){ event.returnValue = "Do you really want to close this window"; }else{ event.returnValue = true; }
}
window.onbeforeunload = close;and u can put a "save" button on your popup page. The user can save the data themselves.
Good day,Good job,Good life