如何在新标签页中打开页面,但又不给它焦点?(JSF 2.0) [英] How to open a page in a new tab but don't give it focus?(JSF 2.0)

查看:216
本文介绍了如何在新标签页中打开页面,但又不给它焦点?(JSF 2.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的是在新标签页中打开页面,但不要将焦点放在新打开的标签页上. 因此,如果我单击几次,则可以打开一些选项卡.

What i want is to open a page in a new tab but don't give focus to the new opened tab. So if i click a few times i can open a few tabs.

就像我右键单击一个链接并说在新标签页中打开一样(我仅在chrome和firefox浏览器中尝试过此操作).

Just as if i right clicked a link and said open in new tab(I tried that only in chrome and firefox browsers).

你知道有可能吗?

当前,我使用带有如下所示按钮的表单打开新标签页:

Currently i open new tabs using a form with a button that looks like this:

<h:form target="_blank">
         <h:commandButton action="#{mainPageBB.toLink}"/>  
</h:form>

推荐答案

与其他许多改变客户端默认行为的事情一样,HTML/JS根本不可能做到这一点,因此JSF只是一个HTML/JS代码生成器不能为你做很多事.它可能会被认为是侵入性的,从而导致不良的用户体验,这也是为什么target="_blank"被弃用的原因.最好的办法是添加一些不打扰和有用的说明,即最终用户可以可以使用Ctrl + Click在新选项卡中打开链接而无需集中精力.

As with many other things which changes the client default behaviour, that's simply not possible by HTML/JS, so JSF as being just a HTML/JS code generator already can't do much for you. It could namely be experienced as intruding and thus result in Bad User Experience, that's also why among others the target="_blank" is deprecated. Best what you can do is to add some non-disturbing and helpful remark that the enduser could use Ctrl+Click to open the links in new tabs without focusing it.

<p class="note">Consider using Ctrl+Click whenever you want to open links in the background in new tabs.</p>.

到那时,这可能是特定于浏览器的/相关的配置设置,因此它可能无法在所有浏览器中都这样工作.毕竟,只需提供一堆链接,然后让客户决定如何处理.

Still then, this could be a browser-specific/dependent configuration setting, so it may not work that way in all browsers. After all, just provide a bunch of links and let the client decide what to do with it.

这篇关于如何在新标签页中打开页面,但又不给它焦点?(JSF 2.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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