0

Here is my requirement,

I'm working on a enterprise application which is quite old, and it supports IE browser only. Now, there are chances that the user could open multiple tab/window from this application. I have written a custom timeout plugin for our purpose with jQuery idleTimer Plugin. When the countdown reaches 10 or less than 10, i need to switch to this tab/window to make the user aware that the page gets expired in less than 10 seconds.

So, is there a solution for this? I have tried window.focus() but does not work.

Dipin Krishnan
  • 1,260
  • 3
  • 21
  • 41
  • Maybe there's a better solution to detect which window is active and show the information there. Or in all open windows, it's the same application after all which should expire all tabs? – baloo Mar 24 '13 at 16:53
  • 2
    How about `alert('Your session is about to expire ...');` – Kijewski Mar 24 '13 at 16:56
  • [May be this can help](http://stackoverflow.com/questions/2704206/how-to-change-browser-focus-from-one-tab-to-another) – Naveen Mar 24 '13 at 16:57

2 Answers2

4

There isn't a cross-browser way do switch a tab that's 100% reliable, especially in newer browsers. It's actively blocked in most newer browsers. As a user, I'm glad it's difficult in most cases, impossible in others to do this.

CrazyFellow
  • 420
  • 3
  • 8
2

If I understand your question correctly, setting a timeout for a Javascript alert in one page then move to another tab, the alert appearing after the timeout will trigger tab switch.

setTimeout(function(){ 
    alert("Switched tabs");
}, 
5000);
William
  • 740
  • 2
  • 11
  • 18