How to open a page in a new tab but don't give it focus?(JSF 2.0)

[亡魂溺海] 提交于 2019-12-20 03:17:34

问题


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.

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

Do you know is it possible?

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>

回答1:


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.



来源:https://stackoverflow.com/questions/7161363/how-to-open-a-page-in-a-new-tab-but-dont-give-it-focusjsf-2-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!