Javascript - How to make a browser switch tabs?

前端 未结 2 1320
悲&欢浪女
悲&欢浪女 2021-01-15 16:02

In my code a timed event launches a ModalDialog. If the user switches tabs before the event the tab blinks but that is it.

Is there a way to make the browser switch

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-15 16:58

    There is no reliable way to do that. The Internet Explorers are the most cooperative about raising windows (which is what switching tabs amounts to), while Safari pretty much ignores all such requests. Firefox can be configured (by its user, not by your code) to allow windows to grab focus, but it's rare for anybody to do that.

    You can have your code call window.focus() but don't rely on it to work.

提交回复
热议问题