I am catching the “close” event for tab, but how I can which tab was closed?
safari.application.addEventListener("close", function(e){
// all e.target values are undefined, which is not helpful..
},true)
Do you have any idea?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
At the moment the event is captured, the properties of e.target (the closed tab) are not undefined. I’m guessing you’re using something like
console.log(e.target)and then examining the logged object in the console. You’re seeing undefined properties then because the event has already finished propagating.Try this instead:
You will see that the tab’s properties are still defined at the moment of event capture, so you can compare them to previously stored values; or, if you have previously assigned the desired tab to a variable, you can even compare e.target itself to that variable.