Search code examples
javascripthtmlurltabstableau-api

Force page to open a new tab on each button click instead of overwriting


We have a site we're working on that is somewhat of a research source. We have an embedded Tableau dashboard with buttons on the main page that each lead to a different page with the same base url but different query parameters. For example:

What we would like is for a new tab to open on each click so the user can come back to that resource later. Currently, the first button click does open a new tab but each subsequent click overwrites the tab that was opened with the first click. Is there an HTML or Javascript way of solving this problem? Since the buttons are within the embedded Tableau dashboard, they don't have access to a right click by the user.


Solution

  • You can add the target="_blank" attribute to the link:

    <a href="wherever" target="_blank">Link</a>
    

    And you can just put the button in the link so whenever someone clicks on the button it will open a new tab.

    <a href="wherever" target="_blank">
        <button>Link</button>
    </a>