简体   繁体   中英

How to open a page in a new tab but don't give it focus?(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.

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM