# Set Link Button to Open in a New Tab

> Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add…

Source: https://tadabase.com/docs/snippets/set-link-button-to-open-in-a-new-tab  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

> **Warning:** Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add this functionality is through the plugin installation wizard. Learn more about plugins [here](https://tadabase.com/docs).

This snippet allows you to set a link button to open in a new browser tab.

![Screenshot for “Set Link Button to Open in a New Tab”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/openlinkinnewtab.gif)

**1. Add the newTab class to the Link Button and set the Page Link to the current page.**

> **Note:** Note: Setting the Page Link to the current page will 'disable' the default link settings. You will then add a custom link using the code below.

![Screenshot for “Set Link Button to Open in a New Tab”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/image-1663091096241.png)

**2. Add the following code into the JavaScript tab of the page. Replace /sample/page with the link of the page you are opening and component_xx with your component number.**

JavaScript Code:

```
TB.render('component_XX',function(data){
        $(".newTab").click(function() {  
      window.open('/sample/page', '_blank');
    });
});
```

![Screenshot for “Set Link Button to Open in a New Tab”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/image-1663090536178.png)

**Find the Component Number**

You can find your component number by hovering over the info icon at the top of the component in the builder.

![Screenshot for “Set Link Button to Open in a New Tab”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-09/scaled-1680-/image-1663090037735.png)

**Multiple Link Buttons**

The attribute `target="_blank"` can only be applied to `<a href` links, not button links, so the only way to use a single script to target all of the buttons on a page would be to create custom HTML buttons in an HTML module and give them the same class. (You can replace `newTab` with any class name you choose.)

Then you could use the following JavaScript code:

```
$(document).ready(function() {
    
  $('a.newTab').click(function(){
    window.open(this.href);
    return false;
  });
});
```

**Original Community Post:**

[https://community.tadabase.io/t/link-button-target-new-window/2131/6](https://community.tadabase.io/t/link-button-target-new-window/2131/6)
