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
test vijaytest vijay 

How to Prevent user to switch console tab with unsaved changes in Lightning Aura Component

I have a lightning aura component with 2 filed firstname,Lastname and a save button. if user try to switch on another console tab(Not browser tab) then show a message do you want to switch another tab if yes then switch and if no stay user of that page.
AbhishekAbhishek (Salesforce Developers) 
Ravi,

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 to the 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/


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.