Is it possible to switch browser tab?(是否可以切换浏览器选项卡?)
问题描述
这是我的要求,
我正在开发一个相当老的企业应用程序,它只支持 IE 浏览器.现在,用户有可能从此应用程序中打开多个选项卡/窗口.我使用 jQuery idleTimer Plugin 为我们的目的编写了一个自定义超时插件.当倒计时达到 10 或小于 10 时,我需要切换到此选项卡/窗口,以使用户知道该页面将在 10 秒内过期.
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.
那么,有没有办法解决这个问题?我试过 window.focus()
但不起作用.
So, is there a solution for this? I have tried window.focus()
but does not work.
推荐答案
没有一种跨浏览器的方式可以切换 100% 可靠的选项卡,尤其是在较新的浏览器中.它在大多数较新的浏览器中被主动阻止.作为用户,我很高兴在大多数情况下很难做到这一点,而在其他情况下是不可能做到的.
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.
这篇关于是否可以切换浏览器选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!