If in some of my tabs alert() is executed, then this tab becomes selected instantly. The thing is - this alert() box is ugly. I have created with my design and all.. But when I call it - tab is not selected/focused. window.focus(); does not work. Any ideas?
Asked
Active
Viewed 6,516 times
7
-
Have you tried overriding the `window.alert` function? i.e. `window.alert = function(text) {....}` and see if this doesn't solve your problem? – Buhake Sindi Aug 06 '10 at 11:53
-
possible duplicate of [window.focus(), self.focus() not working in firefox](http://stackoverflow.com/questions/2533305/window-focus-self-focus-not-working-in-firefox) – Marcel Korpel Aug 06 '10 at 12:18
-
window.alert = function(text) {....} works but does not provide window focusing. – user338418 Aug 06 '10 at 13:07
1 Answers
2
You cannot reliably force windows or tabs to grab focus. Some browsers are more amenable to the idea than others: IE will generally allow it, but Firefox has to be configured by the user to allow it, and Safari will basically never honor a focus request. (Well, almost never.)

Pointy
- 405,095
- 59
- 585
- 614
-
1
-
I have a simple implementation of this working fine in Safari and Chrome. – thepeer Mar 08 '11 at 16:35
-
4@thepeer, Mind showing us or offering a link to a jsfiddle or something? ;) – ShoeMaker Mar 22 '13 at 12:51
-
-
9
-
I don't have verification, but changing the `document.title` value seems to bring a *window* to focus; perhaps it works on tabs as well. – rvighne Jan 19 '14 at 03:27
-