function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nitish Singh 22Nitish Singh 22 

On Service Cloud console I need to prevent a tab from closing on a condition that there is some data that has not been saved.

I have a custom VF page on service cloud console. In case accidentally the tabs is closed , the unsaved data on the VF page gets lost.

So i need a pop up message when a tab is closed , requesting to save the data first.

How can i achieve this ? 
SandhyaSandhya (Salesforce Developers) 
Hi,

I think you can use something like below.
 
jQuery(window).on('beforeunload', function()
{
  return 'Leaving this page will lose your changes. Are you sure?';
}

Please refer below links for the same.

http://salesforce.stackexchange.com/questions/23780/how-to-pop-up-alert-to-a-user-when-he-she-navigate-away-from-page-without-saving

Confirming a User Really Wants to Leave a Page with JavaScript

http://michaelwelburn.com/2013/04/08/confirming-a-user-really-wants-to-leave-a-visualforce-page/


Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
 
Thanks and Regards
Sandhya

 
Nitish Singh 22Nitish Singh 22
The beforeunload event is not getting trigerred