user1688401
user1688401

Reputation: 1871

close all browser tabs except current tab via javascript

I want to close all active tab except the current tab. Is this possible?

In my web site, when a user uses many tabs in same browser it fails. I want to close all tabs except the current one when any events triggered.

Here is a solution that I found:

function close_window() {
    if (confirm("Close Window?")) {
      close();
    }
}

This will work but how can I access other tabs?

Upvotes: 1

Views: 3921

Answers (1)

Greg
Greg

Reputation: 2173

You can't directly control other tabs. You could instead pass them information by writing to cookies or local storage and having all tabs monitor that space.

However, I think that if your site doesn't work when open in multiple tabs, you should be focusing on fixing that problem.

Upvotes: 2

Related Questions