How to change browser focus from one tab to another

前端 未结 6 632
暗喜
暗喜 2020-11-28 14:01

I have a JavaScript chat client running in one browser tab (call it tab A). Now when a message arrives the user might be on another browser tab (call it tab B). I\'m looking

6条回答
  •  失恋的感觉
    2020-11-28 14:43

    It is possible to shift focus back to Tab A by means of an alert in Tab A e.g. alert('New Message')

    However, you need to be careful using this as it is very likely to annoy people. You should only use it if you make it optional in your app. Otherwise, updating Tab A's title and/or the favicon would appear to be best as nc3b says.

提交回复
热议问题