如何将焦点设置为已在Firefox中打开的标签? [英] How to set focus to already opened tab in firefox?

查看:78
本文介绍了如何将焦点设置为已在Firefox中打开的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a link which opens a page in a new tab in firefox.

我有一个链接,在firefox的新标签中打开一个页面。 href ='/ portal.html'>
前往Portal
< / a>

<a target="_default" href='/portal.html' > Go to Portal </a>

然而,当我再次点击此链接时, 会刷新打开的选项卡,并且不会't设置焦点 ,因此用户无法知道该标签已打开。

However when I click this link again ,it refreshes the opened tab and doesn't set focus to it , so users have no way to know that tab is opened .

有什么方法可以让我抓住打开的选项卡并在打开一次后设置关注后续点击或任何其他解决方法。

Is there any way by which I can grab the opened tab and set focus on subsequent clicks after opening it once Or any other workaround .

感谢。

推荐答案

使用tabhandler名称获得焦点可能会有所帮助..假设我们有

For getting the focus using a tabhandler name may help.. suppose we have

win = window.open("https://www.google.com", "test");

win.focus();

现在每当上面的代码运行时,浏览器首先会找到名称为 test ,然后使用url https://www.google.com 重新加载它,并且如果它未找到名称为测试它会打开一个新的。在第二行的运行中,它会将焦点设置为从第一行加载的同一个标签。

now every time the first line of above code runs the browser will first find the tab with the name test and reload it with the url https://www.google.com and in case it does not find a tab with the name test it will open a new one. On the run of the second line it will set the focus to the same tab loaded from the first line.

这篇关于如何将焦点设置为已在Firefox中打开的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆