C Sharper
C Sharper

Reputation: 8646

How To Identify Last Active Tab On Browser

If multiple tabs are active on browser. Lets say -

Tab-1 : google.com

Tab-2 : youtube.com

Tab-3 : Facebook.com

Now if I open my website in Tab-4 : example.com and switch to Tab-2 and then again come to Tab-4 , then on example.com (application I am building right now), I want to identify I have came there from youtube.com

How can I do it in Javascript or jQuery?

Note :-

To identify active tab I have written code :-

document.addEventListener("visibilitychange", function() {
      document.title = document.hidden ? "I'm away" : "I'm here";
});

Upvotes: 0

Views: 402

Answers (1)

blacksun1
blacksun1

Reputation: 116

You don't have any way to see what window you came from as this would be a security violation.

Upvotes: 1

Related Questions