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
Chris VogeChris Voge 

triggering a javascript function when closing inactive subtab

Hello

If I have multiple subtabs open and I click the "x" to close
one of the inactive subtabs, it there a way to trigger a javascript
function ?

I tried window.onunload and window.onbeforeunload, but they only seem to work
when the subtab is the active one.

Thanks.
VikashVikash (Salesforce Developers) 
Hi Chris,

Please try this sample code which is used to detetct the incavtive tab:

window.addEventListener("focus", function() {
  console.log("focus");
},false);

window.addEventListener("blur",function() {
  console.log("blur");
},false);

You need to play around this code and get the required fuction.

Thanks
Vikash_SFDC