In Webflow, is there a way to redirect the current tab to a new page while also opening a different page in a new tab when a button is clicked?

Published on
September 22, 2023

Yes, in Webflow, it is possible to redirect the current tab to a new page while also opening a different page in a new tab when a button is clicked. This can be achieved by using a combination of the built-in Link Settings and Custom Code options in Webflow. Here's a step-by-step guide on how to achieve this functionality:

  1. First, open your Webflow project and go to the page where you want to add the button that triggers the redirection.

  2. Add a button element to the page by dragging and dropping the Button component from the Webflow Designer's Add Panel.

  3. Select the button and navigate to the Link Settings panel on the right-hand side of the Designer.

  4. In the Link settings panel, enter the URL of the page you want to redirect the current tab to in the "Link URL" field. This will be the page that opens in the current tab when the button is clicked.

  5. Next, switch to the Custom Code tab located below the Link Settings panel.

  6. In the Custom Code tab, enter the following JavaScript code:

<script>  document.getElementById("your-button-id").addEventListener("click", function(event){    window.open('https://example.com', '_blank');  });</script>

Replace "your-button-id" with the actual ID of your button element. Replace "https://example.com" with the URL of the page you want to open in a new tab when the button is clicked.

  1. Click outside the code input area to apply the code.

  2. Finally, publish your Webflow project for the changes to take effect.

By following these steps, when the button is clicked, the current tab will be redirected to the URL specified in the Link Settings, and a new tab will open with the URL specified in the JavaScript code.

Additional Questions:

  1. How can I open a new tab while redirecting the current tab in Webflow?
  2. Can I use JavaScript to open a new tab in Webflow when a button is clicked?
  3. Is it possible to have both a current tab redirection and a new tab opening with one button click in Webflow?